Commit 6abe1256 authored by fallenstardust's avatar fallenstardust

移除native sound_effect_enable

parent aa0b41c4
......@@ -18,13 +18,11 @@ inline static void ReadString(irr::io::path &path, char*& p) {
}
InitOptions::InitOptions(void*data) :
m_opengles_version(0), m_card_quality(0), m_font_aa_enabled(TRUE), m_se_enabled(
TRUE) {
m_opengles_version(0), m_card_quality(0), m_font_aa_enabled(TRUE) {
if (data != NULL) {
char* rawdata = (char*)data;
int tmplength = 0;
m_opengles_version = BufferIO::ReadInt32(rawdata);
m_se_enabled = BufferIO::ReadInt32(rawdata) > 0;
m_card_quality = BufferIO::ReadInt32(rawdata);
m_font_aa_enabled = BufferIO::ReadInt32(rawdata) > 0;
......@@ -801,35 +799,6 @@ int getLocalAddr(ANDROID_APP app) {
return addr;
}
bool isSoundEffectEnabled(ANDROID_APP app) {
bool isEnabled = false;
if (!app || !app->activity || !app->activity->vm)
return isEnabled;
JNIEnv* jni = 0;
app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni)
return true;
// Retrieves NativeActivity.
jobject lNativeActivity = app->activity->clazz;
jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity);
jmethodID MethodGetApp = jni->GetMethodID(ClassNativeActivity,
"getApplication", "()Landroid/app/Application;");
jobject application = jni->CallObjectMethod(lNativeActivity, MethodGetApp);
jclass classApp = jni->GetObjectClass(application);
jmethodID MethodCheckSE = jni->GetMethodID(classApp, "isSoundEffectEnabled",
"()Z");
jboolean result = jni->CallBooleanMethod(application, MethodCheckSE);
if (result > 0) {
isEnabled = true;
} else {
isEnabled = false;
}
jni->DeleteLocalRef(ClassNativeActivity);
jni->DeleteLocalRef(classApp);
app->activity->vm->DetachCurrentThread();
return isEnabled;
}
void showAndroidComboBoxCompat(ANDROID_APP app, bool pShow, char** pContents,
int count, int mode) {
if (!app || !app->activity || !app->activity->vm)
......
......@@ -42,9 +42,6 @@ public:
inline bool isFontAntiAliasEnabled() {
return m_font_aa_enabled;
}
inline bool isSoundEffectEnabled() {
return m_se_enabled;
}
inline bool isPendulumScaleEnabled() {
return m_ps_enabled;
}
......@@ -68,7 +65,6 @@ private:
int cdb_count;
int zip_count;
bool m_font_aa_enabled;
bool m_se_enabled;
bool m_ps_enabled;
};
......@@ -171,8 +167,6 @@ extern void saveSetting(ANDROID_APP app, const char* key, const char* value);
//Retrive font antialias options
extern bool getFontAntiAlias(ANDROID_APP app);
extern bool isSoundEffectEnabled(ANDROID_APP app);
//Show Android compat gui;
extern void showAndroidComboBoxCompat(ANDROID_APP app, bool pShow,
char** pContents, int count, int mode = 0);
......
......@@ -16,18 +16,15 @@ import cn.garymb.ygomobile.core.IrrlichtBridge;
public abstract class GameApplication extends Application implements IrrlichtBridge.IrrlichtApplication {
private SoundPool mSoundEffectPool;
private Map<String, Integer> mSoundIdMap;
private static GameApplication sGameApplication;
private boolean isInitSoundEffectPool=false;
@Override
public void onCreate() {
super.onCreate();
sGameApplication = this;
// Reflection.unseal(this);
// initSoundEffectPool();
}
public static GameApplication get() {
......@@ -42,15 +39,6 @@ public abstract class GameApplication extends Application implements IrrlichtBri
@Override
public void onTerminate() {
super.onTerminate();
mSoundEffectPool.release();
}
public boolean isInitSoundEffectPool() {
return isInitSoundEffectPool;
}
protected void setInitSoundEffectPool(boolean initSoundEffectPool) {
isInitSoundEffectPool = initSoundEffectPool;
}
public int getGameWidth(){
......@@ -63,24 +51,6 @@ public abstract class GameApplication extends Application implements IrrlichtBri
public abstract boolean isKeepScale();
@SuppressWarnings("deprecation")
public void initSoundEffectPool() {
mSoundEffectPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0);
AssetManager am = getAssets();
String[] sounds;
mSoundIdMap = new HashMap<String, Integer>();
try {
sounds = am.list("sound");
for (String sound : sounds) {
String path = "sound" + File.separator + sound;
mSoundIdMap
.put(path, mSoundEffectPool.load(am.openFd(path), 1));
}
} catch (IOException e) {
e.printStackTrace();
}
}
public abstract NativeInitOptions getNativeInitOptions();
public abstract float getSmallerSize();
......@@ -105,11 +75,4 @@ public abstract class GameApplication extends Application implements IrrlichtBri
*/
public abstract boolean isImmerSiveMode();
@Override
public void playSoundEffect(String path) {
Integer id = mSoundIdMap.get(path);
if (id != null) {
mSoundEffectPool.play(id, 0.5f, 0.5f, 2, 0, 1.0f);
}
}
}
......@@ -11,7 +11,6 @@ public final class NativeInitOptions {
private static final int BUFFER_MAX_SIZE = 8192;
public int mOpenglVersion;
public boolean mIsSoundEffectEnabled;
//工作目录
public String mWorkPath;
......@@ -36,7 +35,6 @@ public final class NativeInitOptions {
public ByteBuffer toNativeBuffer() {
ByteBuffer buffer = ByteBuffer.allocateDirect(BUFFER_MAX_SIZE);
putInt(buffer, mOpenglVersion);
putInt(buffer, mIsSoundEffectEnabled ? 1 : 0);
putInt(buffer, mCardQuality);
putInt(buffer, mIsFontAntiAliasEnabled ? 1 : 0);
putInt(buffer, mIsPendulumScaleEnabled ? 1 : 0);
......@@ -57,7 +55,6 @@ public final class NativeInitOptions {
public String toString() {
return "NativeInitOptions{" +
"mOpenglVersion=" + mOpenglVersion +
", mIsSoundEffectEnabled=" + mIsSoundEffectEnabled +
", mWorkPath='" + mWorkPath + '\'' +
", mDbList='" + mDbList + '\'' +
", mArchiveList='" + mArchiveList + '\'' +
......
......@@ -172,8 +172,6 @@ public final class IrrlichtBridge {
float getScreenWidth();
float getScreenHeight();
void playSoundEffect(String path);
void runWindbot(String args);
......
......@@ -29,10 +29,6 @@ public class App extends GameApplication {
//初始化异常工具类
CrashHandler crashHandler = CrashHandler.getInstance();
crashHandler.init(getApplicationContext());
if (AppsSettings.get().isSoundEffect()) {
initSoundEffectPool();
setInitSoundEffectPool(true);
}
//初始化图片选择器
initImgsel();
//初始化bugly
......
......@@ -197,7 +197,6 @@ public class AppsSettings {
options.mCardQuality = getCardQuality();
options.mIsFontAntiAliasEnabled = isFontAntiAlias();
options.mIsPendulumScaleEnabled = isPendulumScale();
options.mIsSoundEffectEnabled = isSoundEffect();
options.mOpenglVersion = getOpenglVersion();
if (Constants.DEBUG) {
Log.i("Irrlicht", "option=" + options);
......@@ -262,20 +261,6 @@ public class AppsSettings {
}
}
/***
* 音效
*/
public boolean isSoundEffect() {
return mSharedPreferences.getBoolean(Constants.PREF_SOUND_EFFECT, Constants.PREF_DEF_SOUND_EFFECT);
}
/***
* 音效
*/
public void setSoundEffect(boolean soundEffect) {
mSharedPreferences.putBoolean(Constants.PREF_SOUND_EFFECT, soundEffect);
}
/***
* 决斗助手
*/
......
......@@ -28,8 +28,6 @@ public interface Constants {
int PREF_DEF_OPENGL_VERSION = 1;
String PREF_PENDULUM_SCALE = "pref_key_game_lab_pendulum_scale";
boolean PREF_DEF_PENDULUM_SCALE = true;
String PREF_SOUND_EFFECT = "pref_key_game_sound_effect";
boolean PREF_DEF_SOUND_EFFECT = true;
String PREF_START_SERVICEDUELASSISTANT = "pref_key_start_serviceduelassistant";
boolean PREF_DEF_START_SERVICEDUELASSISTANT = false;
String PREF_LOCK_SCREEN = "pref_key_game_screen_orientation";
......
......@@ -70,7 +70,6 @@ import static cn.garymb.ygomobile.Constants.PREF_OPENGL_VERSION;
import static cn.garymb.ygomobile.Constants.PREF_PENDULUM_SCALE;
import static cn.garymb.ygomobile.Constants.PREF_READ_EX;
import static cn.garymb.ygomobile.Constants.PREF_SENSOR_REFRESH;
import static cn.garymb.ygomobile.Constants.PREF_SOUND_EFFECT;
import static cn.garymb.ygomobile.Constants.PREF_START_SERVICEDUELASSISTANT;
import static cn.garymb.ygomobile.Constants.PREF_USE_EXTRA_CARD_CARDS;
import static cn.garymb.ygomobile.Constants.SETTINGS_AVATAR;
......@@ -125,7 +124,6 @@ public class SettingFragment extends PreferenceFragmentPlus {
bind(PREF_CHANGE_LOG, SystemUtils.getVersionName(getActivity())
+ "(" + SystemUtils.getVersion(getActivity()) + ")");
bind(PREF_CHECK_UPDATE, getString(R.string.settings_about_author_pref) + " : " + getString(R.string.settings_author));
bind(PREF_SOUND_EFFECT, mSettings.isSoundEffect());
bind(PREF_START_SERVICEDUELASSISTANT, mSettings.isServiceDuelAssistant());
bind(PREF_LOCK_SCREEN, mSettings.isLockSreenOrientation());
bind(PREF_FONT_ANTIALIAS, mSettings.isFontAntiAlias());
......@@ -199,15 +197,6 @@ public class SettingFragment extends PreferenceFragmentPlus {
getActivity().stopService(new Intent(getActivity(), ServiceDuelAssistant.class));
}
}
//如果是音效开关
if (preference.getKey().equals(PREF_SOUND_EFFECT)) {
//如果打勾开启音效
if (checkBoxPreference.isChecked()) {
//如果未初始化音效
if (App.get().isInitSoundEffectPool())
App.get().initSoundEffectPool();
}
}
return true;
}
boolean rs = super.onPreferenceChange(preference, value);
......
......@@ -45,12 +45,6 @@
android:key="pref_settings_read_ex"
android:persistent="true"
android:title="@string/title_use_ex" />
<!-- 启用游戏音效
<CheckBoxPreference
android:key="pref_key_game_sound_effect"
android:persistent="true"
android:title="@string/settings_game_enable_sound_effect" />
-->
<CheckBoxPreference
android:key="pref_key_game_screen_orientation"
android:persistent="true"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment