Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkfalcon committed Oct 26, 2021
1 parent 536a404 commit b30333b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions CreativeMode/CreativeMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void OnEnable() {
[HarmonyPrefix]
[HarmonyPatch(typeof(BuildingUnlockingService), "Unlocked")]
static bool BuildingUnlocker(ref bool __result) {
if (!creativeModeEnabled || !disableScienceCost.Value) {
if (!(creativeModeEnabled && disableScienceCost.Value)) {
return true;
}
__result = true;
Expand All @@ -61,7 +61,7 @@ static bool BuildingUnlocker(ref bool __result) {
[HarmonyPrefix]
[HarmonyPatch(typeof(BuildingPlacer), "Place")]
static bool PlaceInstantly(BlockObject prefab) {
if (!creativeModeEnabled || enableInstantBuilding.Value) {
if (creativeModeEnabled && enableInstantBuilding.Value) {
Building component = prefab.GetComponent<Building>();
component.PlaceFinished = true;
}
Expand Down Expand Up @@ -126,12 +126,14 @@ static void HideOldMapEditorTool(ToolGroup ____toolGroup, ref bool __result) {
*/
[HarmonyPostfix]
[HarmonyPatch(typeof(OptionsBox), "GetPanel")]
static void AddCreativeModeToggle(ref VisualElement __result) {
static void AddCreativeModeToggle(ref VisualElement __result, OptionsBox __instance) {
VisualElement root = __result.Children().First();
IEnumerable<string> buttonStyle = root.Children().First().GetClasses();

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

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

public static void ToggleCreativeMode() {
public static void ToggleCreativeMode(OptionsBox optionsBox) {
creativeModeEnabled = !creativeModeEnabled;
optionsBox.ResumeClicked();
}
}
}
2 changes: 1 addition & 1 deletion UnifiedFactions/UnifiedFactions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static void AddToggleButton(ref VisualElement __result) {
"block-object-rotation-panel__button"
},
style = {
color = new Color(0.75f, 0.65f, 0.44f)
color = Color.white
}
};

Expand Down

0 comments on commit b30333b

Please sign in to comment.