Description:
Refactor StyleSets slightly.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -0,0 +1,65 | |||
|
1 | ||
|
2 | using System.Collections.Generic; | |
|
3 | using ImGuiNET; | |
|
4 | ||
|
5 | using Num = System.Numerics; | |
|
6 | ||
|
7 | ||
|
8 | namespace isometricparkfna.UI | |
|
9 | { | |
|
10 | public static class StyleSets | |
|
11 | { | |
|
12 | public static Num.Vector4 grey = new Num.Vector4(0.75f, 0.75f, 0.75f, 1f); | |
|
13 | public static Num.Vector4 darkgrey = new Num.Vector4(0.45f, 0.45f, 0.45f, 1f); | |
|
14 | public static Num.Vector4 black = new Num.Vector4(0f, 0f, 0f, 1f); | |
|
15 | public static Num.Vector4 white = new Num.Vector4(1f, 1f, 1f, 1f); | |
|
16 | public static Num.Vector4 title_bar = new Num.Vector4(0.65f, 0.65f, 0.65f, 1f); | |
|
17 | ||
|
18 | // public static Num.Vector4 selected = new Num.Vector4(0.0f, 0.0f, 0.75f, 1f); | |
|
19 | public static Num.Vector4 selected = new Num.Vector4(0.0f, 0.0f, 0.55f, 1f); | |
|
20 | public static Dictionary<ImGuiStyleVar, float> defaultWindowVars = new Dictionary<ImGuiStyleVar, float>{ | |
|
21 | { ImGuiStyleVar.FrameRounding, 0.0f }, | |
|
22 | {ImGuiStyleVar.WindowRounding, 0.0f}, | |
|
23 | {ImGuiStyleVar.FrameBorderSize, 1.0f}, | |
|
24 | {ImGuiStyleVar.TabRounding, 0.0f}, | |
|
25 | }; | |
|
26 | public static Dictionary<ImGuiCol, Num.Vector4> defaultWindowColors = new Dictionary<ImGuiCol, Num.Vector4>{ | |
|
27 | ||
|
28 | {ImGuiCol.WindowBg, grey}, | |
|
29 | {ImGuiCol.FrameBg, grey}, | |
|
30 | {ImGuiCol.FrameBgHovered, grey}, | |
|
31 | {ImGuiCol.Header, darkgrey}, | |
|
32 | {ImGuiCol.HeaderHovered, darkgrey}, | |
|
33 | {ImGuiCol.HeaderActive, darkgrey}, | |
|
34 | {ImGuiCol.ButtonHovered, grey}, | |
|
35 | {ImGuiCol.ButtonActive, darkgrey}, | |
|
36 | {ImGuiCol.SliderGrab, darkgrey}, | |
|
37 | {ImGuiCol.SliderGrabActive, darkgrey}, | |
|
38 | ||
|
39 | ||
|
40 | {ImGuiCol.Tab, darkgrey}, | |
|
41 | {ImGuiCol.TabHovered, darkgrey}, | |
|
42 | {ImGuiCol.TabActive, selected}, | |
|
43 | ||
|
44 | {ImGuiCol.CheckMark, black}, | |
|
45 | ||
|
46 | {ImGuiCol.TitleBg, title_bar}, | |
|
47 | {ImGuiCol.TitleBgActive, selected}, | |
|
48 | {ImGuiCol.TitleBgCollapsed, title_bar}, | |
|
49 | ||
|
50 | {ImGuiCol.Border, black}, | |
|
51 | {ImGuiCol.BorderShadow, black}, | |
|
52 | ||
|
53 | {ImGuiCol.PopupBg, white}, | |
|
54 | ||
|
55 | {ImGuiCol.Button, grey}, | |
|
56 | {ImGuiCol.Text, black} | |
|
57 | }; | |
|
58 | ||
|
59 | public static StyleSet defaultSet = new StyleSet(defaultWindowVars, defaultWindowColors); | |
|
60 | ||
|
61 | ||
|
62 | ||
|
63 | } | |
|
64 | ||
|
65 | } |
@@ -36,11 +36,11 | |||
|
36 | 36 | public List<SetResolutionMessage> resolutionMessages; |
|
37 | 37 | public List<SetFontMessage> fontMessages; |
|
38 | 38 | |
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
39 | bool showBudget {get;} | |
|
40 | bool showForest {get;} | |
|
41 | bool showNews {get;} | |
|
42 | bool showGrid {get;} | |
|
43 | bool showTrees {get;} | |
|
44 | 44 | |
|
45 | 45 | public Dictionary<Window, bool> windowStatuses {get;} |
|
46 | 46 |
@@ -36,8 +36,8 | |||
|
36 | 36 | bool newShow = true; |
|
37 | 37 | |
|
38 | 38 | // Num.Vector2 button_size = new Num.Vector2(120, 20); |
|
39 | StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars); | |
|
40 | StyleSet.pushColorSet(StyleSet.defaultWindowColors); | |
|
39 | ||
|
40 | StyleSets.defaultSet.push(); | |
|
41 | 41 | |
|
42 | 42 | |
|
43 | 43 | // ImGui.SetNextWindowPos(new Num.Vector2(width/2, 200)); |
@@ -140,8 +140,7 | |||
|
140 | 140 | ImGui.End(); |
|
141 | 141 | |
|
142 | 142 | ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left; |
|
143 | StyleSet.popStyleVarSet(StyleSet.defaultWindowVars); | |
|
144 | StyleSet.popColorSet(StyleSet.defaultWindowColors); | |
|
143 | StyleSets.defaultSet.pop(); | |
|
145 | 144 | ImGui.PopFont(); |
|
146 | 145 | |
|
147 | 146 | if (!newShow) |
@@ -56,8 +56,6 | |||
|
56 | 56 | }; |
|
57 | 57 | |
|
58 | 58 | // public static IMFont |
|
59 | /* | |
|
60 | */ | |
|
61 | 59 | public static void pushStyleVarSet(Dictionary<ImGuiStyleVar, float> style_set) |
|
62 | 60 | { |
|
63 | 61 | foreach(var pair in style_set) |
@@ -82,6 +80,32 | |||
|
82 | 80 | { |
|
83 | 81 | ImGui.PopStyleColor(style_set.Count); |
|
84 | 82 | } |
|
83 | ||
|
84 | public Dictionary<ImGuiStyleVar, float> WindowVars {get;} | |
|
85 | public Dictionary<ImGuiCol, Num.Vector4> WindowColors {get;} | |
|
86 | ||
|
87 | public StyleSet(Dictionary<ImGuiStyleVar, float> windowVars, | |
|
88 | Dictionary<ImGuiCol, Num.Vector4> windowColors | |
|
89 | ) | |
|
90 | { | |
|
91 | ||
|
92 | this.windowVars = windowVars; | |
|
93 | this.windowColors = windowColors; | |
|
94 | } | |
|
95 | ||
|
96 | public void push() | |
|
97 | { | |
|
98 | StyleSet.pushColorSet(this.windowColors); | |
|
99 | StyleSet.pushStyleVarSet(this.windowVars); | |
|
100 | } | |
|
101 | ||
|
102 | public void pop() | |
|
103 | { | |
|
104 | StyleSet.popColorSet(this.windowColors); | |
|
105 | StyleSet.popStyleVarSet(this.windowVars); | |
|
106 | } | |
|
107 | ||
|
108 | ||
|
85 | 109 | } |
|
86 | 110 | |
|
87 | 111 | } |
@@ -65,6 +65,7 | |||
|
65 | 65 | <Compile Include="UI\Menu.cs" /> |
|
66 | 66 | <Compile Include="UI\NewsWindow.cs" /> |
|
67 | 67 | <Compile Include="UI\StyleSet.cs" /> |
|
68 | <Compile Include="UI\StyleSets.cs" /> | |
|
68 | 69 | <Compile Include="UI\MainMenu.cs" /> |
|
69 | 70 | <Compile Include="UI\InGameMenu.cs" /> |
|
70 | 71 | <Compile Include="UI\OptionsWindow.cs" /> |
You need to be logged in to leave comments.
Login now