Skip to content

Commit b30333b

Browse files
author
hawkfalcon
committed
Tweaks
1 parent 536a404 commit b30333b

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

CreativeMode/CreativeMode.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void OnEnable() {
4848
[HarmonyPrefix]
4949
[HarmonyPatch(typeof(BuildingUnlockingService), "Unlocked")]
5050
static bool BuildingUnlocker(ref bool __result) {
51-
if (!creativeModeEnabled || !disableScienceCost.Value) {
51+
if (!(creativeModeEnabled && disableScienceCost.Value)) {
5252
return true;
5353
}
5454
__result = true;
@@ -61,7 +61,7 @@ static bool BuildingUnlocker(ref bool __result) {
6161
[HarmonyPrefix]
6262
[HarmonyPatch(typeof(BuildingPlacer), "Place")]
6363
static bool PlaceInstantly(BlockObject prefab) {
64-
if (!creativeModeEnabled || enableInstantBuilding.Value) {
64+
if (creativeModeEnabled && enableInstantBuilding.Value) {
6565
Building component = prefab.GetComponent<Building>();
6666
component.PlaceFinished = true;
6767
}
@@ -126,12 +126,14 @@ static void HideOldMapEditorTool(ToolGroup ____toolGroup, ref bool __result) {
126126
*/
127127
[HarmonyPostfix]
128128
[HarmonyPatch(typeof(OptionsBox), "GetPanel")]
129-
static void AddCreativeModeToggle(ref VisualElement __result) {
129+
static void AddCreativeModeToggle(ref VisualElement __result, OptionsBox __instance) {
130130
VisualElement root = __result.Children().First();
131131
IEnumerable<string> buttonStyle = root.Children().First().GetClasses();
132132

133-
Button button = CreateButton("Toggle Creative Mode", buttonStyle);
134-
button.clicked += ToggleCreativeMode;
133+
string text = "Toggle Creative Mode " + (creativeModeEnabled ? "Off" : "On");
134+
Button button = CreateButton(text, buttonStyle);
135+
OptionsBox optionsBox = __instance;
136+
button.clicked += () => ToggleCreativeMode(__instance);
135137
root.Insert(4, button);
136138
}
137139

@@ -147,8 +149,9 @@ private static Button CreateButton(string name, IEnumerable<string> styles) {
147149
return button;
148150
}
149151

150-
public static void ToggleCreativeMode() {
152+
public static void ToggleCreativeMode(OptionsBox optionsBox) {
151153
creativeModeEnabled = !creativeModeEnabled;
154+
optionsBox.ResumeClicked();
152155
}
153156
}
154157
}

UnifiedFactions/UnifiedFactions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static void AddToggleButton(ref VisualElement __result) {
185185
"block-object-rotation-panel__button"
186186
},
187187
style = {
188-
color = new Color(0.75f, 0.65f, 0.44f)
188+
color = Color.white
189189
}
190190
};
191191

0 commit comments

Comments
 (0)