Reworked options menu as a prefab and changed pause menu a bit. Need to work on option loading (Currently still old mechanic) and jumping cam when striving and looking.

This commit is contained in:
finnchen123
2026-02-22 12:42:52 +01:00
parent 72d1dae796
commit 85e659e23c
46 changed files with 15286 additions and 1555 deletions

View File

@@ -24,18 +24,6 @@ namespace Assets.Scripts
fight = GameObject.Find("Fight");
}
public void openOptions()
{
audioHandler.playButtonClick();
uihandler.openOptions();
}
public void closeOptions()
{
audioHandler.playButtonClick();
uihandler.closeOptions();
}
public void exitToMenu()
{
audioHandler.playButtonClick();
@@ -78,22 +66,6 @@ namespace Assets.Scripts
player.upgradeSecondary();
}
public void saveOptions()
{
string saveText = "";
audioHandler.playButtonClick();
saveText = saveText + uihandler.saveVideoSettings() + "\r\n";
saveText = saveText + uihandler.saveLanguage() + "\r\n";
saveText = saveText + uihandler.saveAudioSettings() + "\r\n";
GameObject.Find("Controls").GetComponent<Controls>().sensitivityMouse = new Vector2(
GameObject.Find("slideSensitivityMouseHorizontal").GetComponent<Slider>().value,
GameObject.Find("slideSensitivityMouseVertical").GetComponent<Slider>().value
);
saveText = saveText + "SensitivityMouse:"+GameObject.Find("slideSensitivityMouseHorizontal").GetComponent<Slider>().value + "/" + GameObject.Find("slideSensitivityMouseVertical").GetComponent<Slider>().value;
FileHandler.saveOptions(saveText);
uihandler.closeOptions();
}
public void closeIntroduction()
{
audioHandler.playButtonClick();

View File

@@ -0,0 +1,97 @@
using Assets.Scripts;
using UnityEngine;
using UnityEngine.UI;
public class OptionHandler : MonoBehaviour
{
public bool isMenu = true;
public void saveOptions()
{
string saveText = "";
saveText = saveText + saveVideoSettings() + "\r\n";
saveText = saveText + saveLanguage() + "\r\n";
saveText = saveText + saveAudioSettings() + "\r\n";
saveText = saveText + "SensitivityMouse:" + GameObject.Find("slideSensitivityMouseHorizontal").GetComponent<Slider>().value + "/" + GameObject.Find("slideSensitivityMouseVertical").GetComponent<Slider>().value;
if (!isMenu)
{
GameObject.Find("Controls").GetComponent<Controls>().sensitivityMouse = new Vector2(
GameObject.Find("slideSensitivityMouseHorizontal").GetComponent<Slider>().value,
GameObject.Find("slideSensitivityMouseVertical").GetComponent<Slider>().value
);
}
FileHandler.saveOptions(saveText);
}
public string saveVideoSettings()
{
GameObject resolution = GameObject.Find("dropResolution");
GameObject mode = GameObject.Find("dropMode");
string result = "";
switch (resolution.GetComponent<Dropdown>().value)
{
case 0:
Screen.SetResolution(800, 600, Screen.fullScreenMode);
break;
case 1:
Screen.SetResolution(1280, 800, Screen.fullScreenMode);
break;
case 2:
Screen.SetResolution(1920, 1080, Screen.fullScreenMode);
break;
}
switch (mode.GetComponent<Dropdown>().value)
{
case 0:
if (Screen.fullScreenMode != FullScreenMode.Windowed)
{
Screen.fullScreenMode = FullScreenMode.Windowed;
}
break;
case 1:
if (Screen.fullScreenMode != FullScreenMode.ExclusiveFullScreen)
{
Screen.fullScreenMode = FullScreenMode.ExclusiveFullScreen;
}
break;
case 2:
if (Screen.fullScreenMode != FullScreenMode.FullScreenWindow)
{
Screen.fullScreenMode = FullScreenMode.FullScreenWindow;
}
break;
}
result = result + "Resolution:" + resolution.GetComponent<Dropdown>().value + "\r\n";
result = result + "Mode:" + mode.GetComponent<Dropdown>().value;
return result;
}
public string saveLanguage()
{
GameObject language = GameObject.Find("dropLanguage");
string result = "";
switch (language.GetComponent<Dropdown>().value)
{
case 0:
result = "de";
break;
case 1:
result = "en";
break;
}
result = "Language:" + result;
return result;
}
public string saveAudioSettings()
{
string result = "";
float music = GameObject.Find("slideMusic").GetComponent<Slider>().value;
float effects = GameObject.Find("slideEffects").GetComponent<Slider>().value;
result = result + "Music:" + music + "\r\n";
result = result + "Effects:" + effects;
return result;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 01be303a57f148e4791a13abf141956a

View File

@@ -115,19 +115,6 @@ namespace Assets.Scripts
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnCloseTutorial"));
}
public void openOptions()
{
FileHandler.loadOptionDisplay();
hideOtherElements(options);
state = UIState.PAUSEOPTIONS;
}
public void closeOptions()
{
state = UIState.PAUSE;
openPauseMenu();
}
public void switchInventory()
{
if (state == UIState.INVENTORY)
@@ -233,77 +220,6 @@ namespace Assets.Scripts
showHUD();
}
public string saveVideoSettings()
{
GameObject resolution = GameObject.Find("dropResolution");
GameObject mode = GameObject.Find("dropMode");
string result = "";
switch (resolution.GetComponent<Dropdown>().value)
{
case 0:
Screen.SetResolution(800, 600, Screen.fullScreenMode);
break;
case 1:
Screen.SetResolution(1280, 800, Screen.fullScreenMode);
break;
case 2:
Screen.SetResolution(1920, 1080, Screen.fullScreenMode);
break;
}
switch (mode.GetComponent<Dropdown>().value)
{
case 0:
if (Screen.fullScreenMode != FullScreenMode.Windowed)
{
Screen.fullScreenMode = FullScreenMode.Windowed;
}
break;
case 1:
if (Screen.fullScreenMode != FullScreenMode.ExclusiveFullScreen)
{
Screen.fullScreenMode = FullScreenMode.ExclusiveFullScreen;
}
break;
case 2:
if (Screen.fullScreenMode != FullScreenMode.FullScreenWindow)
{
Screen.fullScreenMode = FullScreenMode.FullScreenWindow;
}
break;
}
result = result + "Resolution:" + resolution.GetComponent<Dropdown>().value + "\r\n";
result = result + "Mode:" + mode.GetComponent<Dropdown>().value;
return result;
}
public string saveLanguage()
{
GameObject language = GameObject.Find("dropLanguage");
string result = "";
switch (language.GetComponent<Dropdown>().value)
{
case 0:
result = "de";
break;
case 1:
result = "en";
break;
}
result = "Language:" + result;
return result;
}
public string saveAudioSettings()
{
string result = "";
float music = GameObject.Find("slideMusic").GetComponent<Slider>().value;
float effects = GameObject.Find("slideEffects").GetComponent<Slider>().value;
result = result + "Music:" + music + "\r\n";
result = result + "Effects:" + effects;
return result;
}
public void openPauseMenu()
{
hideOtherElements(pauseMenu);