Description:
Really basic indicator.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -1,7 +1,8 | |||||
|
|
1 | using System; | ||
|
1 | using System.Collections.Generic; |
|
2 | using System.Collections.Generic; |
|
2 | using Encompass; |
|
||
|
3 | using System.Linq; |
|
3 | using System.Linq; |
|
4 |
|
4 | ||
|
|
5 | using Encompass; | ||
|
5 | using ImGuiNET; |
|
6 | using ImGuiNET; |
|
6 |
|
7 | ||
|
7 | using isometricparkfna.Messages; |
|
8 | using isometricparkfna.Messages; |
@@ -25,10 +26,8 | |||||
|
25 | typeof(SetDialogMessage))] |
|
26 | typeof(SetDialogMessage))] |
|
26 | [Reads(typeof(VisibilityComponent), |
|
27 | [Reads(typeof(VisibilityComponent), |
|
27 | typeof(WindowTypeComponent), |
|
28 | typeof(WindowTypeComponent), |
|
28 | typeof(TrespassingPolicyComponent) |
|
29 | typeof(TrespassingPolicyComponent), |
|
29 |
|
|
30 | typeof(ContractStatusComponent))] |
|
30 | )] |
|
||
|
31 | // [Writes(typeof(SelectedComponent))] |
|
||
|
32 | public class ImGuiWindowBridgeEngine : Engine |
|
31 | public class ImGuiWindowBridgeEngine : Engine |
|
33 | { |
|
32 | { |
|
34 |
|
33 | ||
@@ -53,11 +52,12 | |||||
|
53 |
|
52 | ||
|
54 | public Dictionary<Window, bool> windowStatuses {get;} |
|
53 | public Dictionary<Window, bool> windowStatuses {get;} |
|
55 |
|
54 | ||
|
|
55 | public bool showContractIndicator; | ||
|
|
56 | |||
|
56 | public ImFontPtr font; |
|
57 | public ImFontPtr font; |
|
57 | public ImFontPtr italicFont; |
|
58 | public ImFontPtr italicFont; |
|
58 | private DebugWindow debugWindow; |
|
59 | private DebugWindow debugWindow; |
|
59 |
|
60 | ||
|
60 |
|
|||
|
61 | public ImGuiWindowBridgeEngine(DebugWindow debugWindow, |
|
61 | public ImGuiWindowBridgeEngine(DebugWindow debugWindow, |
|
62 | ImFontPtr font, ImFontPtr italicFont) |
|
62 | ImFontPtr font, ImFontPtr italicFont) |
|
63 | { |
|
63 | { |
@@ -75,6 +75,7 | |||||
|
75 | this.setDialogMessages = new List<SetDialogMessage>(); |
|
75 | this.setDialogMessages = new List<SetDialogMessage>(); |
|
76 | this.windowStatuses = new Dictionary<Window, bool>(); |
|
76 | this.windowStatuses = new Dictionary<Window, bool>(); |
|
77 |
|
77 | ||
|
|
78 | this.showContractIndicator = false; | ||
|
78 |
|
79 | ||
|
79 | this.font = font; |
|
80 | this.font = font; |
|
80 | this.italicFont = italicFont; |
|
81 | this.italicFont = italicFont; |
@@ -167,6 +168,17 | |||||
|
167 | var type = GetComponent<WindowTypeComponent>(entity).type; |
|
168 | var type = GetComponent<WindowTypeComponent>(entity).type; |
|
168 | var visibility = HasComponent<VisibilityComponent>(entity) ? GetComponent<VisibilityComponent>(entity).visible : false; |
|
169 | var visibility = HasComponent<VisibilityComponent>(entity) ? GetComponent<VisibilityComponent>(entity).visible : false; |
|
169 | windowStatuses[type] = visibility; |
|
170 | windowStatuses[type] = visibility; |
|
|
171 | } | ||
|
|
172 | |||
|
|
173 | //reset | ||
|
|
174 | this.showContractIndicator = false; | ||
|
|
175 | foreach(var entity in ReadEntities<ContractStatusComponent>()) | ||
|
|
176 | { | ||
|
|
177 | var contractStatus = GetComponent<ContractStatusComponent>(entity); | ||
|
|
178 | if(contractStatus.date > new DateTime(2021, 4, 1)) | ||
|
|
179 | { | ||
|
|
180 | this.showContractIndicator = true; | ||
|
|
181 | } | ||
|
170 |
|
182 | ||
|
171 | } |
|
183 | } |
|
172 |
|
184 |
@@ -1,3 +1,5 | |||||
|
|
1 | using System; | ||
|
|
2 | |||
|
1 | using ImGuiNET; |
|
3 | using ImGuiNET; |
|
2 |
|
4 | ||
|
3 | using Num = System.Numerics; |
|
5 | using Num = System.Numerics; |
@@ -22,13 +24,62 | |||||
|
22 | } |
|
24 | } |
|
23 |
|
25 | ||
|
24 | var result = ImGui.Button(label); |
|
26 | var result = ImGui.Button(label); |
|
25 |
|
|||
|
26 | if (active) { |
|
27 | if (active) { |
|
27 | ImGui.PopStyleColor(3); |
|
28 | ImGui.PopStyleColor(3); |
|
28 | } |
|
29 | } |
|
29 |
|
30 | ||
|
30 | return result; |
|
31 | return result; |
|
31 | } |
|
32 | } |
|
|
33 | |||
|
|
34 | private static bool activeButtonIndicator(string label, bool active, Num.Vector4 activeColor, Num.Vector4 activeTextColor, string indicator, Num.Vector4 indicatorColor, string tooltip) { | ||
|
|
35 | |||
|
|
36 | if (active) { | ||
|
|
37 | ImGui.PushStyleColor(ImGuiCol.Button, activeColor); | ||
|
|
38 | ImGui.PushStyleColor(ImGuiCol.ButtonHovered, activeColor); | ||
|
|
39 | ImGui.PushStyleColor(ImGuiCol.Text, activeTextColor); | ||
|
|
40 | } | ||
|
|
41 | |||
|
|
42 | var result = ImGui.Button(String.Format("{0} ", label)); | ||
|
|
43 | ImGui.SetItemAllowOverlap(); | ||
|
|
44 | |||
|
|
45 | |||
|
|
46 | if (active) { | ||
|
|
47 | ImGui.PopStyleColor(3); | ||
|
|
48 | } | ||
|
|
49 | |||
|
|
50 | var dimensions = ImGui.CalcTextSize(indicator); | ||
|
|
51 | |||
|
|
52 | ImGui.PushStyleColor(ImGuiCol.Text, indicatorColor); | ||
|
|
53 | //Found through trial and error: | ||
|
|
54 | ImGui.SetCursorPosX(ImGui.GetCursorPosX() -(dimensions.X + 10)); | ||
|
|
55 | ImGui.Text(indicator); | ||
|
|
56 | ImGui.PopStyleColor(); | ||
|
|
57 | |||
|
|
58 | |||
|
|
59 | if (ImGui.IsItemHovered()) | ||
|
|
60 | { | ||
|
|
61 | var rect = ImGui.GetItemRectMax(); | ||
|
|
62 | ImGui.SetNextWindowPos(rect + new Num.Vector2(15, 0)); | ||
|
|
63 | ImGui.BeginTooltip(); | ||
|
|
64 | ImGui.Text(tooltip); | ||
|
|
65 | ImGui.EndTooltip(); | ||
|
|
66 | } | ||
|
|
67 | |||
|
|
68 | return result; | ||
|
|
69 | } | ||
|
|
70 | |||
|
|
71 | private static bool contractsButton(ImGuiWindowBridgeEngine bridgeEngine) | ||
|
|
72 | { | ||
|
|
73 | if (bridgeEngine.showContractIndicator) | ||
|
|
74 | { | ||
|
|
75 | return Menu.activeButtonIndicator("\ue0c2 Contracts", bridgeEngine.windowStatuses[Window.Contracts], StyleSets.selected, StyleSets.white, "(!)", StyleSets.red, "Contract Offer X will expire"); | ||
|
|
76 | } | ||
|
|
77 | else | ||
|
|
78 | { | ||
|
|
79 | return Menu.activeButton("\ue0c2 Contracts", bridgeEngine.windowStatuses[Window.Contracts], StyleSets.selected, StyleSets.white); | ||
|
|
80 | } | ||
|
|
81 | } | ||
|
|
82 | |||
|
32 | public static void Render(ImFontPtr font, int width, ImGuiWindowBridgeEngine bridgeEngine, ref bool quit, ref bool paused, ref int rate, ref bool showBudget, string header) |
|
83 | public static void Render(ImFontPtr font, int width, ImGuiWindowBridgeEngine bridgeEngine, ref bool quit, ref bool paused, ref int rate, ref bool showBudget, string header) |
|
33 | { |
|
84 | { |
|
34 | ImGui.PushFont(font); |
|
85 | ImGui.PushFont(font); |
@@ -49,14 +100,14 | |||||
|
49 | // Add 12 pixels for each button, plus separator |
|
100 | // Add 12 pixels for each button, plus separator |
|
50 | ImGui.SetCursorPosX(width - (dimensions.X + 11*12)); |
|
101 | ImGui.SetCursorPosX(width - (dimensions.X + 11*12)); |
|
51 |
|
102 | ||
|
52 | if (Menu.activeButton("\ue0c2 Contracts", bridgeEngine.windowStatuses[Window.Contracts], StyleSets.selected, StyleSets.white)) |
|
103 | if (contractsButton(bridgeEngine)) |
|
53 | { |
|
104 | { |
|
54 | Logging.Trace("Contracts toggled."); |
|
105 | Logging.Trace("Contracts toggled."); |
|
55 | Logging.Spy(bridgeEngine.windowStatuses, "statuses"); |
|
106 | Logging.Spy(bridgeEngine.windowStatuses, "statuses"); |
|
56 | bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Contracts}); |
|
107 | bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Contracts}); |
|
57 | } |
|
108 | } |
|
58 | //Budget isn't connected to an entity yet: |
|
109 | //Budget isn't connected to an entity yet: |
|
59 | if (Menu.activeButton("$ Budget", showBudget, StyleSets.selected, StyleSets.white)) |
|
110 | if (Menu.activeButton("$ Budget", showBudget, StyleSets.selected, StyleSets.white)) //" \ue0b2 ", StyleSets.red, "New budget" |
|
60 | { |
|
111 | { |
|
61 | bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Budget}); |
|
112 | bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Budget}); |
|
62 |
|
113 |
@@ -10,11 +10,14 | |||||
|
10 | public static class StyleSets |
|
10 | public static class StyleSets |
|
11 | { |
|
11 | { |
|
12 | public static Num.Vector4 grey = new Num.Vector4(0.75f, 0.75f, 0.75f, 1f); |
|
12 | public static Num.Vector4 grey = new Num.Vector4(0.75f, 0.75f, 0.75f, 1f); |
|
|
13 | public static Num.Vector4 grey_transparent = new Num.Vector4(0.75f, 0.75f, 0.75f, 0.25f); | ||
|
13 | public static Num.Vector4 darkgrey = new Num.Vector4(0.45f, 0.45f, 0.45f, 1f); |
|
14 | 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 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 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 | public static Num.Vector4 title_bar = new Num.Vector4(0.65f, 0.65f, 0.65f, 1f); |
|
17 |
|
18 | ||
|
|
19 | public static Num.Vector4 red = new Num.Vector4(1f, 0.0f, 0.20f, 1f); | ||
|
|
20 | |||
|
18 | // public static Num.Vector4 selected = new Num.Vector4(0.0f, 0.0f, 0.75f, 1f); |
|
21 | // 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); |
|
22 | 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>{ |
|
23 | public static Dictionary<ImGuiStyleVar, float> defaultWindowVars = new Dictionary<ImGuiStyleVar, float>{ |
@@ -53,7 +56,7 | |||||
|
53 |
|
56 | ||
|
54 | {ImGuiCol.PopupBg, white}, |
|
57 | {ImGuiCol.PopupBg, white}, |
|
55 |
|
58 | ||
|
56 | {ImGuiCol.Button, grey}, |
|
59 | {ImGuiCol.Button, grey_transparent}, |
|
57 | {ImGuiCol.Text, black} |
|
60 | {ImGuiCol.Text, black} |
|
58 | }; |
|
61 | }; |
|
59 |
|
62 |
You need to be logged in to leave comments.
Login now