// Path: src/com/lvonasek/o4s/media/Settings.java
// public class Settings {
// 
//     public static final int          MUSIC_VOLUME   = 0;
//     public static final int          SOUND_VOLUME   = 1;
//     public static final int          VISUAL_QUALITY = 2;
//     public static final int          RACE_EVENT     = 3;
// 
//     public static final String       RACE_CUSTOM_EVENT = "O4SCFG";
// 
//     private static int[]             DEFAULT_VALUES = {100, 100, 100, 0};
// 
//     public static void init(Activity instance) {
//         Display display = instance.getWindowManager().getDefaultDisplay();
//         Point size = new Point();
//         display.getSize(size);
//         int level = 25 + (int) ((Math.max(size.x, size.y) - 800) / 6.4f);
//         level = Math.max(0, Math.min(level, 100));
//         DEFAULT_VALUES[VISUAL_QUALITY] = level;
//         Log.v("Open4speed", "Default visual quality=" + level);
//     }
// 
//     public static int getConfig(Context c, int index) {
//         SharedPreferences pref = c.getSharedPreferences("MyPref", Context.MODE_PRIVATE);
//         return pref.getInt("IntCFG" + index, DEFAULT_VALUES[index]);
//     }
// 
//     public static void setConfig(Context c, int index, int value) {
//         SharedPreferences pref = c.getSharedPreferences("MyPref", Context.MODE_PRIVATE);
//         SharedPreferences.Editor edit = pref.edit();
//         edit.putInt("IntCFG" + index, value);
//         edit.commit();
//     }
// 
//     public static String getConfig(Context c, String str) {
//         SharedPreferences pref = c.getSharedPreferences("MyPref", Context.MODE_PRIVATE);
//         return pref.getString(str, "");
//     }
// 
//     public static void setConfig(Context c, String str, String value) {
//         SharedPreferences pref = c.getSharedPreferences("MyPref", Context.MODE_PRIVATE);
//         SharedPreferences.Editor edit = pref.edit();
//         edit.putString(str, value);
//         edit.commit();
//     }
// }
// 
// Path: src/com/lvonasek/o4s/media/Sound.java
// public class Sound {
// 
//     public static SoundPool snd = new SoundPool(16, AudioManager.STREAM_MUSIC, 0);
// 
//     public static float globalVolume = 1;
// 
//     int id;
//     boolean loop;
//     boolean playing;
//     float rate;
//     float volume;
// 
//     public Sound(String filename, boolean loop) {
//         //unzip file(Android java access)
//         try {
//             AssetFileDescriptor afd = GameActivity.instance.getAssets().openFd(filename);
//             id = snd.load(afd, 1);
//         } catch (IOException e) {
//             e.printStackTrace();
//             this.id = -1;
//         }
//         this.loop = loop;
//         this.rate = 1;
//         this.volume = 0;
//         playing = false;
//     }
// 
//     public void play() {
//         if (GameLoop.paused == 0) {
//             //play sound
//             if (playing)
//                 snd.pause(id);
//             snd.play(id, volume, volume, 1, loop ? -1 : 1, rate);
//             playing = true;
//         }
//     }
// 
//     /**
//      * Change frequency of sound(engine, n2o)
//      * @param speed is play rate(from 0.5 to 2.0)
//      */
//     public void setFreq(float speed) {
//         //clamp rate speed
//         rate = speed;
//         if (speed < 0.5) {
//             rate = 0.5f;
//         }
//         if (speed > 2.0) {
//             rate = 2.0f;
//         }
//     }
// 
//     /**
//      * Set sound volume
//      * @param volume is sound volume(from 0 to 1)
//      */
//     public void setVolume(float volume) {
//         //audio clip
//         if (GameLoop.paused == 0) {
//             volume *= 0.25f;
//             this.volume = volume * globalVolume;
//         }
//     }
// 
//     /**
//      * Stops playing sound
//      */
//     public void stop() {
//         //audio clip
//         if ((GameLoop.paused == 0) && playing) {
//             snd.stop(id);
//             playing = false;
//         }
//     }
// }


import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.opengl.GLSurfaceView;
import android.opengl.GLSurfaceView.Renderer;
import android.util.AttributeSet;
import android.view.View;
import com.lvonasek.o4s.R;
import com.lvonasek.o4s.media.Settings;
import com.lvonasek.o4s.media.Sound;
import java.util.ArrayList;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
            sounds.add(new Sound("sfx/engineplus.ogg", true));
        }
        //begin
        setRenderer(this);
    }

    /**
     * Second init method - this is called when everything is ready
     * @param gl OpenGL object(unused because it is for java OpenGL interpretation)
     * @param config another OpenGL object(unused because it is for java OpenGL interpretation)
     */
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        //check if it is first time run
        if (!GameActivity.instance.init) {

            //get package assets object
            String apkFilePath;
            ApplicationInfo appInfo;
            PackageManager packMgmr = GameActivity.instance.getPackageManager();

            //try to get assets
            try {
                appInfo = packMgmr.getApplicationInfo("com.lvonasek.o4s", 0);
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException("Unable to locate assets, aborting...");
            }

            //load game
            apkFilePath = appInfo.sourceDir;
// Path: src/com/lvonasek/o4s/media/Settings.java
// public class Settings {
// 
//     public static final int          MUSIC_VOLUME   = 0;
//     public static final int          SOUND_VOLUME   = 1;
//     public static final int          VISUAL_QUALITY = 2;
//     public static final int          RACE_EVENT     = 3;
// 
//     public static final String       RACE_CUSTOM_EVENT = "O4SCFG";
// 
//     private static int[]             DEFAULT_VALUES = {100, 100, 100, 0};
// 
//     public static void init(Activity instance) {
//         Display display = instance.getWindowManager().getDefaultDisplay();
//         Point size = new Point();
//         display.getSize(size);
//         int level = 25 + (int) ((Math.max(size.x, size.y) - 800) / 6.4f);
//         level = Math.max(0, Math.min(level, 100));
//         DEFAULT_VALUES[VISUAL_QUALITY] = level;
//         Log.v("Open4speed", "Default visual quality=" + level);
//     }
// 
//     public static int getConfig(Context c, int index) {
//         SharedPreferences pref = c.getSharedPreferences("MyPref", Context.MODE_PRIVATE);
//         return pref.getInt("IntCFG" + index, DEFAULT_VALUES[index]);
//     }
// 
//     public static void setConfig(Context c, int index, int value) {
//         SharedPreferences pref = c.getSharedPreferences("MyPref", Context.MODE_PRIVATE);
//         SharedPreferences.Editor edit = pref.edit();
//         edit.putInt("IntCFG" + index, value);
//         edit.commit();
//     }
// 
//     public static String getConfig(Context c, String str) {
//         SharedPreferences pref = c.getSharedPreferences("MyPref", Context.MODE_PRIVATE);
//         return pref.getString(str, "");
//     }
// 
//     public static void setConfig(Context c, String str, String value) {
//         SharedPreferences pref = c.getSharedPreferences("MyPref", Context.MODE_PRIVATE);
//         SharedPreferences.Editor edit = pref.edit();
//         edit.putString(str, value);
//         edit.commit();
//     }
// }
// 
// Path: src/com/lvonasek/o4s/media/Sound.java
// public class Sound {
// 
//     public static SoundPool snd = new SoundPool(16, AudioManager.STREAM_MUSIC, 0);
// 
//     public static float globalVolume = 1;
// 
//     int id;
//     boolean loop;
//     boolean playing;
//     float rate;
//     float volume;
// 
//     public Sound(String filename, boolean loop) {
//         //unzip file(Android java access)
//         try {
//             AssetFileDescriptor afd = GameActivity.instance.getAssets().openFd(filename);
//             id = snd.load(afd, 1);
//         } catch (IOException e) {
//             e.printStackTrace();
//             this.id = -1;
//         }
//         this.loop = loop;
//         this.rate = 1;
//         this.volume = 0;
//         playing = false;
//     }
// 
//     public void play() {
//         if (GameLoop.paused == 0) {
//             //play sound
//             if (playing)
//                 snd.pause(id);
//             snd.play(id, volume, volume, 1, loop ? -1 : 1, rate);
//             playing = true;
//         }
//     }
// 
//     /**
//      * Change frequency of sound(engine, n2o)
//      * @param speed is play rate(from 0.5 to 2.0)
//      */
//     public void setFreq(float speed) {
//         //clamp rate speed
//         rate = speed;
//         if (speed < 0.5) {
//             rate = 0.5f;
//         }
//         if (speed > 2.0) {
//             rate = 2.0f;
//         }
//     }
// 
//     /**
//      * Set sound volume
//      * @param volume is sound volume(from 0 to 1)
//      */
//     public void setVolume(float volume) {
//         //audio clip
//         if (GameLoop.paused == 0) {
//             volume *= 0.25f;
//             this.volume = volume * globalVolume;
//         }
//     }
// 
//     /**
//      * Stops playing sound
//      */
//     public void stop() {
//         //audio clip
//         if ((GameLoop.paused == 0) && playing) {
//             snd.stop(id);
//             playing = false;
//         }
//     }
// }


// Path: src/com/lvonasek/o4s/game/GameLoop.java
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.opengl.GLSurfaceView;
import android.opengl.GLSurfaceView.Renderer;
import android.util.AttributeSet;
import android.view.View;
import com.lvonasek.o4s.R;
import com.lvonasek.o4s.media.Settings;
import com.lvonasek.o4s.media.Sound;
import java.util.ArrayList;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

            sounds.add(new Sound("sfx/engineplus.ogg", true));
        }
        //begin
        setRenderer(this);
    }

    /**
     * Second init method - this is called when everything is ready
     * @param gl OpenGL object(unused because it is for java OpenGL interpretation)
     * @param config another OpenGL object(unused because it is for java OpenGL interpretation)
     */
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        //check if it is first time run
        if (!GameActivity.instance.init) {

            //get package assets object
            String apkFilePath;
            ApplicationInfo appInfo;
            PackageManager packMgmr = GameActivity.instance.getPackageManager();

            //try to get assets
            try {
                appInfo = packMgmr.getApplicationInfo("com.lvonasek.o4s", 0);
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException("Unable to locate assets, aborting...");
            }

            //load game
            apkFilePath = appInfo.sourceDir;
            float quality = 0.01f * Settings.getConfig(GameActivity.instance, Settings.VISUAL_QUALITY);