add ability to specify gui style for area

This commit is contained in:
in0finite 2021-02-06 23:20:21 +01:00
parent 933c3ed089
commit 899711abda
3 changed files with 10 additions and 9 deletions

View file

@ -529,7 +529,7 @@ namespace SanAndreasUnity.Behaviours
if (null == m_fileBrowser) {
Rect rect = GUIUtils.GetCenteredRect (FileBrowser.GetRecommendedSize());
m_fileBrowser = new FileBrowser(rect, "Select path to GTA", (string path) => {
m_fileBrowser = new FileBrowser(rect, "Select path to GTA", GUI.skin.window, (string path) => {
m_showFileBrowser = false;
Config.SetString (Config.const_game_dir, path);
Config.SaveUserConfigSafe ();

View file

@ -35,7 +35,7 @@ namespace SanAndreasUnity.UI {
// create file browser
if (null == m_fileBrowser)
{
m_fileBrowser = new FileBrowser (new Rect (new Vector2 (8, 30), new Vector2(this.WindowSize.x - 16, this.WindowSize.y - 30 - 10)), "", this.OnSelectedPath) {
m_fileBrowser = new FileBrowser (new Rect (new Vector2 (8, 30), new Vector2(this.WindowSize.x - 16, this.WindowSize.y - 30 - 10)), "", null, this.OnSelectedPath) {
BrowserType = FileBrowserType.Directory
};
}

View file

@ -126,6 +126,7 @@ public class FileBrowser {
protected string m_name;
protected Rect m_screenRect;
protected GUIStyle m_areaStyle;
protected Vector2 m_scrollPosition;
@ -133,10 +134,10 @@ public class FileBrowser {
// Browsers need at least a rect, name and callback
public FileBrowser(Rect screenRect, string name, FinishedCallback callback) {
public FileBrowser(Rect screenRect, string name, GUIStyle areaStyle, FinishedCallback callback) {
m_name = name;
m_screenRect = screenRect;
m_areaStyle = areaStyle;
m_browserType = FileBrowserType.File;
m_callback = callback;
SetNewDirectory(Directory.GetCurrentDirectory());
@ -355,11 +356,11 @@ public class FileBrowser {
}
public void OnGUI() {
GUILayout.BeginArea(
m_screenRect,
m_name
);
if (m_areaStyle != null)
GUILayout.BeginArea(m_screenRect, m_name, m_areaStyle);
else
GUILayout.BeginArea(m_screenRect, m_name);
// display top panel
if (m_topPanelEntries.Count > 0) {