Skip to content

Commit

Permalink
aaa
Browse files Browse the repository at this point in the history
  • Loading branch information
Sisah2 committed Mar 24, 2024
1 parent f11be01 commit 939dbfa
Show file tree
Hide file tree
Showing 11 changed files with 253 additions and 58 deletions.
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@
android:exported="true"
android:label="@string/visuals_activity_settings"
/>
<activity
android:name="ui.activity.Shadows_SettingsActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="fullUser"
android:theme="@style/MyTheme"
android:exported="true"
android:label="@string/shadows_activity_settings"
/>
<activity
android:name="ui.activity.Animations_SettingsActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
Expand Down
8 changes: 0 additions & 8 deletions app/src/main/java/ui/activity/GameActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,6 @@ class GameActivity : SDLActivity() {
if (textureShrinkingOption == "medium") Os.setenv("LIBGL_SHRINK", "7", true)
if (textureShrinkingOption == "high") Os.setenv("LIBGL_SHRINK", "6", true)

val shaderDirOption = prefs!!.getString("pref_shadersDir_v2", "")
if (shaderDirOption == "modified") Os.setenv("OPENMW_SHADERS", "modified", true)
if (shaderDirOption == "zesterer") Os.setenv("OPENMW_SHADERS", "zesterer", true)

if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("pref_nohighp", false) && shaderDirOption == "modified") {
Os.setenv("LIBGL_NOHIGHP", "1", true)
}

Os.setenv("OSG_VERTEX_BUFFER_HINT", "VBO", true)
Os.setenv("OPENMW_USER_FILE_STORAGE", Constants.USER_FILE_STORAGE + "/", true)
//Os.setenv("OSG_NOTIFY_LEVEL", "FATAL", true) //hide osg errors for now, gl4es bug.
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/ui/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,27 @@ class MainActivity : AppCompatActivity() {
writeSetting("Post Processing", "soft particles", if(prefs.getBoolean("gs_soft_particles", false)) "true" else "false")
writeSetting("Post Processing", "transparent postpass", if(prefs.getBoolean("gs_transparent_postpass", false)) "true" else "false")

// Visuals Shadows
if(prefs.getBoolean("gs_object_shadows", false) || prefs.getBoolean("gs_terrain_shadows", false) ||
prefs.getBoolean("gs_actor_shadows", false) || prefs.getBoolean("gs_player_shadows", false)) {

writeSetting("Shadows", "enable shadows",
if(prefs.getBoolean("gs_object_shadows", false) || prefs.getBoolean("gs_terrain_shadows", false) ||
prefs.getBoolean("gs_actor_shadows", false) || prefs.getBoolean("gs_player_shadows", false))
"true" else "false")

writeSetting("Shadows", "object shadows", if(prefs.getBoolean("gs_object_shadows", false)) "true" else "false")
writeSetting("Shadows", "terrain shadows", if(prefs.getBoolean("gs_terrain_shadows", false)) "true" else "false")
writeSetting("Shadows", "actor shadows", if(prefs.getBoolean("gs_actor_shadows", false)) "true" else "false")
writeSetting("Shadows", "player shadows", if(prefs.getBoolean("gs_player_shadows", false)) "true" else "false")
writeSetting("Shadows", "indoor shadows", if(prefs.getBoolean("gs_indoor_shadows", true)) "true" else "false")
writeSetting("Shadows", "shadow map resolution", prefs.getString("gs_shadow_map_resolution", "1024").toString())
writeSetting("Shadows", "compute scene bounds", prefs.getString("gs_shadow_computation_method", "bounds").toString())
writeSetting("Shadows", "maximum shadow map distance", prefs.getString("gs_shadows_distance", "8192").toString())
writeSetting("Shadows", "shadow fade start", prefs.getString("gs_shadows_fade_start", "0.9").toString())
writeSetting("Shadows", "percentage closer filtering", prefs.getString("gs_shadows_pcf", "1").toString())
}

// Animations
writeSetting("Game", "use magic item animations", if(prefs.getBoolean("gs_use_magic_item_animation", false)) "true" else "false")
writeSetting("Game", "use additional anim sources", if(prefs.getBoolean("gs_use_additional_animation_sources", false)) "true" else "false")
Expand Down
95 changes: 94 additions & 1 deletion app/src/main/java/ui/activity/SettingsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ import android.preference.Preference
import android.preference.PreferenceFragment
import android.preference.PreferenceGroup

import constants.Constants
import android.widget.Toast
import android.opengl.EGL14.EGL_CONTEXT_CLIENT_VERSION
import android.opengl.EGL14.EGL_OPENGL_ES2_BIT
import android.opengl.GLES20
import javax.microedition.khronos.egl.EGL10
import javax.microedition.khronos.egl.EGL10.*
import javax.microedition.khronos.egl.EGLConfig
import javax.microedition.khronos.egl.EGLContext
import javax.microedition.khronos.egl.EGLDisplay

class FragmentGameSettings : PreferenceFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -71,6 +82,12 @@ class FragmentGameSettings : PreferenceFragment() {
true
}

findPreference("game_settings_shadows").setOnPreferenceClickListener {
val intent = Intent(activity, Shadows_SettingsActivity::class.java)
this.startActivity(intent)
true
}

findPreference("game_settings_animations").setOnPreferenceClickListener {
val intent = Intent(activity, Animations_SettingsActivity::class.java)
this.startActivity(intent)
Expand Down Expand Up @@ -154,7 +171,60 @@ class FragmentGameSettingsPage(val res: Int) : PreferenceFragment(), OnSharedPre
addPreferencesFromResource(res)
preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(this)

if (res == R.xml.gs_game_mechanics) findPreference("gs_always_allow_npc_to_follow_over_water_surface").isEnabled = preferenceScreen.sharedPreferences.getBoolean("gs_build_navmesh", true)
val config = intArrayOf(
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_DEPTH_SIZE, 0,
EGL_STENCIL_SIZE, 0,
EGL_NONE
)

fun chooseEglConfig(egl: EGL10, eglDisplay: EGLDisplay) : EGLConfig {
val configsCount = intArrayOf(0);
val configs = arrayOfNulls<EGLConfig>(1);
egl.eglChooseConfig(eglDisplay, config, configs, 1, configsCount)
return configs[0]!!
}

fun getExtensionList() {
val egl = EGLContext.getEGL() as EGL10
val eglDisplay = egl.eglGetDisplay(EGL_DEFAULT_DISPLAY)
egl.eglInitialize(eglDisplay, intArrayOf(0,0)) // getting OpenGL ES 2
val eglConfig = chooseEglConfig(egl, eglDisplay);
val eglContext = egl.eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, intArrayOf(EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE));

//FIXME: Create some surface to dont rely on extension, pbuffer require egl 1.4 what is better?
//val eglSurface = egl.eglCreateWindowSurface(eglDisplay, eglConfig, texture_view.surfaceTexture, null)
if (egl.eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglContext) == true) {
val extensions = GLES20.glGetString(GLES20.GL_EXTENSIONS)
File(Constants.USER_CONFIG + "/extensions.cfg").writeText(extensions.replace(" ", "\n"))

egl.eglDestroyContext(eglDisplay, eglContext)
//egl.eglDestroySurface(eglDisplay, eglSurface)

if (extensions.contains("GL_EXT_depth_clamp") == false) {
findPreference("gs_object_shadows").isEnabled = false
findPreference("gs_terrain_shadows").isEnabled = false
findPreference("gs_actor_shadows").isEnabled = false
findPreference("gs_player_shadows").isEnabled = false
findPreference("gs_indoor_shadows").isEnabled = false
findPreference("gs_shadow_map_resolution").isEnabled = false
findPreference("gs_shadow_computation_method").isEnabled = false
findPreference("gs_shadows_distance").isEnabled = false
findPreference("gs_shadows_fade_start").isEnabled = false
findPreference("gs_shadows_pcf").isEnabled = false
}
}
else Toast.makeText(this.getActivity(), "Cant check for extensions!", Toast.LENGTH_SHORT).show()
}

if (res == R.xml.gs_shadows) getExtensionList()

// what is this?
//if (res == R.xml.gs_game_mechanics) findPreference("gs_always_allow_npc_to_follow_over_water_surface").isEnabled = preferenceScreen.sharedPreferences.getBoolean("gs_build_navmesh", true)

if (res == R.xml.gs_animations) updatePreference(preferenceScreen.sharedPreferences, "gs_use_additional_animation_sources")
if (res == R.xml.gs_engine) updatePreference(preferenceScreen.sharedPreferences, "gs_build_navmesh")
Expand Down Expand Up @@ -229,6 +299,29 @@ class Visuals_SettingsActivity : AppCompatActivity() {
}
}

class Shadows_SettingsActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_settings)

setSupportActionBar(findViewById(R.id.settings_toolbar))
supportActionBar?.setDisplayHomeAsUpEnabled(true)

fragmentManager.beginTransaction().replace(R.id.settings_frame, FragmentGameSettingsPage(R.xml.gs_shadows)).commit()
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
android.R.id.home -> {
onBackPressed()
true
}
else -> super.onOptionsItemSelected(item)
}
}
}

class Animations_SettingsActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
11 changes: 0 additions & 11 deletions app/src/main/java/ui/fragments/FragmentSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,6 @@ class FragmentSettings : PreferenceFragment(), OnSharedPreferenceChangeListener
val sharedPref = preferenceScreen.sharedPreferences
findPreference("pref_gamma").isEnabled =
sharedPref.getString("pref_graphicsLibrary_v2", "") != "gles1"

var isnohighpenabled = false;
if(sharedPref.getString("pref_shadersDir_v2", "") == "modified")
isnohighpenabled = true
findPreference("pref_nohighp").isEnabled = isnohighpenabled
/*
var isAdditionalAnimSourcesEnabled = false;
if(sharedPref.getBoolean("gs_use_additional_animation_sources", false) == true) isAdditionalAnimSourcesEnabled = true
findPreference("gs_weapon_sheating").isEnabled = isAdditionalAnimSourcesEnabled
findPreference("gs_shield_sheating").isEnabled = isAdditionalAnimSourcesEnabled
*/
}

}
58 changes: 45 additions & 13 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,50 @@
<item>2</item>
</string-array>

<string-array name="gs_shadow_map_resolution_entries">
<item>512</item>
<item>1024</item>
<item>2048</item>
<item>4096</item>
</string-array>

<string-array name="gs_shadow_map_resolution_values">
<item>512</item>
<item>1024</item>
<item>2048</item>
<item>4096</item>
</string-array>

<string-array name="gs_shadow_planes_computation_method_entries">
<item>None</item>
<item>Bounds</item>
<item>Primitives</item>
</string-array>

<string-array name="gs_shadow_planes_computation_method_values">
<item>none</item>
<item>bounds</item>
<item>primitives</item>
</string-array>

<string-array name="gs_shadow_pcf_entries">
<item>Disabled</item>
<item>4 samples</item>
<item>2x2x4 samples</item>
<item>3x3x4 samples</item>
<item>4x4x4 samples</item>
<item>5x5x4 samples</item>
</string-array>

<string-array name="gs_shadow_pcf_values">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
</string-array>

<string name="general_settings">Setup</string>
<string name="start_game_label">Start game</string>
<string name="closeDrawer">Navigation View</string>
Expand All @@ -81,7 +125,6 @@
<string name="pref_graphics">Graphics</string>
<string name="pref_commandLine">Custom command line arguments</string>
<string name="pref_envLine">Custom environment flags</string>
<string name="pref_nohighp">Medium shader precision</string>
<string name="pref_ui">User interface</string>
<string name="pref_textureShrinking">Texture shrinking</string>
<string name="pref_textureShrinking_default">none</string>
Expand Down Expand Up @@ -142,18 +185,6 @@
<item>high</item>
</string-array>

<string-array name="pref_shadersDir_entries">
<item>Original</item>
<item>Modified</item>
<item>Zesterer</item>
</string-array>

<string-array name="pref_shadersDir_values">
<item>none</item>
<item>modified</item>
<item>zesterer</item>
</string-array>

<string name="pref_physicsFPS2_default">30</string>


Expand All @@ -174,6 +205,7 @@
<string name="activity_settings">Settings</string>
<string name="game_mechanics_activity_settings">Game Mechanics</string>
<string name="visuals_activity_settings">Visuals</string>
<string name="shadows_activity_settings">Shadows</string>
<string name="animations_activity_settings">Animations</string>
<string name="interface_activity_settings">Interface</string>
<string name="bug_fixes_activity_settings">Bug Fixes</string>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/xml/game_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
android:title="Visuals"
/>

<Preference
android:key="game_settings_shadows"
android:title="Shadows"
/>

<Preference
android:key="game_settings_animations"
android:title="Animations"
Expand Down
10 changes: 0 additions & 10 deletions app/src/main/res/xml/gs_animations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,4 @@
android:summary="Affects side and diagonal movement. Enabling this setting makes movement more realistic. If disabled then the whole character's body is pointed to the direction of view. Diagonal movement has no special animation and causes sliding. If enabled then the character turns lower body to the direction of movement. Upper body is turned partially. Head is always pointed to the direction of view. In combat mode it works only for diagonal movement. In non-combat mode it changes straight right and straight left movement as well. Also turns the whole body up or down when swimming according to the movement direction."/>

</PreferenceCategory>

<PreferenceCategory android:title="First person">

<CheckBoxPreference
android:key="gs_hand_inertia"
android:title="Hand Inertia"
android:summary="Causes hands to chase view direction slightly when turning, instead of matching the camera perfectly."/>

</PreferenceCategory>

</PreferenceScreen>
79 changes: 79 additions & 0 deletions app/src/main/res/xml/gs_shadows.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

<PreferenceCategory android:title="Shadows">


<CheckBoxPreference
android:key="gs_object_shadows"
android:title="Enable Object Shadows"
android:summary="Enable shadows for primarily inanimate objects. May have a significant performance impact."/>

<CheckBoxPreference
android:key="gs_terrain_shadows"
android:title="Enable Terrain Shadows"
android:summary="Enable shadows for the terrain including distant terrain. May have a significant performance and shadow quality impact."/>

<CheckBoxPreference
android:key="gs_actor_shadows"
android:title="Enable Actors Shadows"
android:summary="Enable shadows for NPCs and creatures besides the player character. May have a minor performance impact."/>

<CheckBoxPreference
android:key="gs_player_shadows"
android:title="Enable Player Shadows"
android:summary="Enable shadows exclusively for the player character. May have a very minor performance impact."/>

<CheckBoxPreference
android:key="gs_indoor_shadows"
android:title="Enable Indoor Shadows"
android:defaultValue="true"
android:summary="Due to limitations with Morrowind's data, only actors can cast shadows indoors, which some might feel is distracting."/>

<ListPreference
android:key="gs_shadow_map_resolution"
android:summary="%s \nThe resolution of each individual shadow map. Increasing it significantly improves shadow quality but may have a minor performance impact."
android:title="Shadow Map Resolution"
android:dialogTitle="Shadow Map Resolution"
android:entries="@array/gs_shadow_map_resolution_entries"
android:entryValues="@array/gs_shadow_map_resolution_values"
android:defaultValue="1024" />

<ListPreference
android:key="gs_shadow_computation_method"
android:summary="%s \nComputation method to be used. Bounds (default) for good balance between performance and shadow quality, primitives for better looking shadows or none for no computation."
android:title="Shadow Planes Computation Method"
android:dialogTitle="Shadow Planes Computation Method"
android:entries="@array/gs_shadow_planes_computation_method_entries"
android:entryValues="@array/gs_shadow_planes_computation_method_values"
android:defaultValue="bounds" />

<EditTextPreference
android:key="gs_shadows_distance"
android:title="Shadows Rendering Distance"
android:dialogTitle="Shadows Distance Limit"
android:inputType="numberDecimal"
android:hint="8192"
android:defaultValue="8192"
android:summary="The distance from the camera at which shadows completely disappear."/>

<EditTextPreference
android:key="gs_shadows_fade_start"
android:title="Fade Start Multiplier"
android:dialogTitle="Shadows Fade Start.\nShould be in 0.0 - 1.0 range."
android:inputType="numberDecimal"
android:hint="0.9"
android:defaultValue="0.9"
android:summary="The fraction of the limit above at which shadows begin to gradually fade away."/>

<ListPreference
android:key="gs_shadows_pcf"
android:summary="%s \nSmooth out shadows edges if small resolution is set. Higher values may have significant performance impact."
android:title="Shadows PCF Filter"
android:dialogTitle="Shadows PCF Filter"
android:entries="@array/gs_shadow_pcf_entries"
android:entryValues="@array/gs_shadow_pcf_values"
android:defaultValue="1" />
</PreferenceCategory>

</PreferenceScreen>
Loading

0 comments on commit 939dbfa

Please sign in to comment.