-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* traverse menus and buttons * lots of methods and events
- Loading branch information
1 parent
198712e
commit 9862542
Showing
28 changed files
with
629 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
namespace OWML.Common | ||
using OWML.Common.Menus; | ||
|
||
namespace OWML.Common | ||
{ | ||
public interface IModHelper | ||
{ | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using UnityEngine.UI; | ||
|
||
namespace OWML.Common.Menus | ||
{ | ||
public interface IModButton | ||
{ | ||
event Action OnClick; | ||
string Title { get; set; } | ||
int Index { get; set; } | ||
Button Button { get; } | ||
void Initialize(IModMenu menu); | ||
|
||
IModButton Copy(); | ||
IModButton Copy(string title); | ||
IModButton Copy(int index); | ||
IModButton Copy(string title, int index); | ||
|
||
IModButton Duplicate(); | ||
IModButton Duplicate(string title); | ||
IModButton Duplicate(int index); | ||
IModButton Duplicate(string title, int index); | ||
|
||
IModButton Replace(); | ||
IModButton Replace(string title); | ||
IModButton Replace(int index); | ||
IModButton Replace(string title, int index); | ||
|
||
void Show(); | ||
void Hide(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace OWML.Common.Menus | ||
{ | ||
public interface IModMainMenu : IModMenu | ||
{ | ||
IModTabbedMenu OptionsMenu { get; } | ||
|
||
IModButton ResumeExpeditionButton { get; } | ||
IModButton NewExpeditionButton { get; } | ||
IModButton OptionsButton { get; } | ||
IModButton ViewCreditsButton { get; } | ||
IModButton SwitchProfileButton { get; } | ||
IModButton QuitButton { get; } | ||
|
||
void Initialize(TitleScreenManager titleScreenManager); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEngine.UI; | ||
|
||
namespace OWML.Common.Menus | ||
{ | ||
public interface IModMenu | ||
{ | ||
event Action OnInit; | ||
|
||
Menu Menu { get; } | ||
List<IModButton> Buttons { get; } | ||
IModButton GetButton(string title); | ||
void AddButton(IModButton button); | ||
void AddButton(IModButton button, int index); | ||
|
||
[Obsolete("Use Buttons instead")] | ||
List<Button> GetButtons(); | ||
[Obsolete("Use button.Duplicate instead")] | ||
Button AddButton(string title, int index); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace OWML.Common.Menus | ||
{ | ||
public interface IModMenus | ||
{ | ||
IModMainMenu MainMenu { get; } | ||
IModPauseMenu PauseMenu { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace OWML.Common.Menus | ||
{ | ||
public interface IModPauseMenu : IModPopupMenu | ||
{ | ||
IModTabbedMenu OptionsMenu { get; } | ||
|
||
IModButton ResumeButton { get; } | ||
IModButton OptionsButton { get; } | ||
IModButton QuitButton { get; } | ||
|
||
void Initialize(SettingsManager settingsManager); | ||
} | ||
} |
9 changes: 7 additions & 2 deletions
9
OWML.Common/IModPopupMenu.cs → OWML.Common/Menus/IModPopupMenu.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
using System; | ||
|
||
namespace OWML.Common | ||
namespace OWML.Common.Menus | ||
{ | ||
public interface IModPopupMenu : IModMenu | ||
{ | ||
Action OnOpen { get; set; } | ||
Action OnClose { get; set; } | ||
Action OnInit { get; set; } | ||
|
||
bool IsOpen { get; } | ||
string Title { get; set; } | ||
|
||
void Open(); | ||
void Close(); | ||
void Toggle(); | ||
|
||
IModPopupMenu Copy(); | ||
IModPopupMenu Copy(string title); | ||
void Initialize(Menu menu); | ||
|
||
[Obsolete("Use Copy instead")] | ||
IModPopupMenu CreateCopy(string name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace OWML.Common.Menus | ||
{ | ||
public interface IModTabMenu : IModPopupMenu | ||
{ | ||
void Initialize(TabButton tabButton); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace OWML.Common.Menus | ||
{ | ||
public interface IModTabbedMenu : IModPopupMenu | ||
{ | ||
IModTabMenu GameplayTab { get; } | ||
IModTabMenu AudioTab { get; } | ||
IModTabMenu InputTab { get; } | ||
IModTabMenu GraphicsTab { get; } | ||
|
||
new IModTabbedMenu Copy(); | ||
|
||
void Initialize(TabbedMenu menu); | ||
new TabbedMenu Menu { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
using System; | ||
using OWML.Common.Menus; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace OWML.ModHelper.Menus | ||
{ | ||
public class ModButton : IModButton | ||
{ | ||
public event Action OnClick; | ||
|
||
public Button Button { get; } | ||
public IModMenu Menu { get; private set; } | ||
|
||
private readonly Text _text; | ||
public string Title | ||
{ | ||
get => _text.text; | ||
set => _text.text = value; | ||
} | ||
|
||
private int _index; | ||
public int Index | ||
{ | ||
get => Button.transform.parent == null ? _index : Button.transform.GetSiblingIndex(); | ||
set | ||
{ | ||
_index = value; | ||
Button.transform.SetSiblingIndex(value); | ||
} | ||
} | ||
|
||
public ModButton(Button button, IModMenu menu) | ||
{ | ||
Button = button; | ||
Button.onClick.AddListener(() => OnClick?.Invoke()); | ||
_text = Button.GetComponentInChildren<Text>(); | ||
Initialize(menu); | ||
} | ||
|
||
public void Initialize(IModMenu menu) | ||
{ | ||
Menu = menu; | ||
} | ||
|
||
public IModButton Copy() | ||
{ | ||
var button = GameObject.Instantiate(Button); | ||
GameObject.Destroy(button.GetComponent<SubmitAction>()); | ||
GameObject.Destroy(button.GetComponentInChildren<LocalizedText>()); | ||
return new ModButton(button, Menu) | ||
{ | ||
Index = Index + 1 | ||
}; | ||
} | ||
|
||
public IModButton Copy(string title) | ||
{ | ||
var copy = Copy(); | ||
copy.Title = title; | ||
return copy; | ||
} | ||
|
||
public IModButton Copy(int index) | ||
{ | ||
var copy = Copy(); | ||
copy.Index = index; | ||
return copy; | ||
} | ||
|
||
public IModButton Copy(string title, int index) | ||
{ | ||
var copy = Copy(title); | ||
copy.Index = index; | ||
return copy; | ||
} | ||
|
||
public IModButton Duplicate() | ||
{ | ||
var copy = Copy(); | ||
Menu.AddButton(copy); | ||
return copy; | ||
} | ||
|
||
public IModButton Duplicate(string title) | ||
{ | ||
var dupe = Duplicate(); | ||
dupe.Title = title; | ||
return dupe; | ||
} | ||
|
||
public IModButton Duplicate(int index) | ||
{ | ||
var dupe = Duplicate(); | ||
dupe.Index = index; | ||
return dupe; | ||
} | ||
|
||
public IModButton Duplicate(string title, int index) | ||
{ | ||
var dupe = Duplicate(title); | ||
dupe.Index = index; | ||
return dupe; | ||
} | ||
|
||
public IModButton Replace() | ||
{ | ||
var duplicate = Duplicate(); | ||
Hide(); | ||
return duplicate; | ||
} | ||
|
||
public IModButton Replace(string title) | ||
{ | ||
var replacement = Replace(); | ||
replacement.Title = title; | ||
return replacement; | ||
} | ||
|
||
public IModButton Replace(int index) | ||
{ | ||
var replacement = Replace(); | ||
replacement.Index = index; | ||
return replacement; | ||
} | ||
|
||
public IModButton Replace(string title, int index) | ||
{ | ||
var replacement = Replace(title); | ||
replacement.Index = index; | ||
return replacement; | ||
} | ||
|
||
public void Show() | ||
{ | ||
Button.gameObject.SetActive(true); | ||
} | ||
|
||
public void Hide() | ||
{ | ||
Button.gameObject.SetActive(false); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.