Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 37 additions & 8 deletions Assets/IceCreamModule.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using IceCream;
using UnityEngine;
Expand Down Expand Up @@ -37,8 +38,12 @@ public class IceCreamModule : MonoBehaviour
// Mod Settings (opening times)
class Settings
{
public bool openingTimeEnabled;
}
public bool? openingTimeEnabled = null;
public bool? hoursCommandEnabled = null;

public bool OpeningTimeEnabled() { return openingTimeEnabled ?? true; }
public bool HoursCommandEnabled() { return hoursCommandEnabled ?? true; }
}
Settings modSettings;

// Flavour Definitions
Expand Down Expand Up @@ -130,8 +135,23 @@ void Start()
{
ModuleID = ModuleIDCounter++;

ModSettings.RefreshSettings();
modSettings = JsonConvert.DeserializeObject<Settings>(ModSettings.Settings);

if (!modSettings.openingTimeEnabled.HasValue || !modSettings.hoursCommandEnabled.HasValue)
{
modSettings.openingTimeEnabled = modSettings.OpeningTimeEnabled();
modSettings.hoursCommandEnabled = modSettings.HoursCommandEnabled();
try
{
File.WriteAllText(ModSettings.SettingsPath ,JsonConvert.SerializeObject(modSettings, Formatting.Indented));
}
catch
{
//
}
}

CorrectFlavors = new int[MaxStages];

LeftButton.OnInteract += delegate { HandlePress(-1); return false; };
Expand Down Expand Up @@ -304,7 +324,7 @@ void RotateFlavours(int dir)
void Submit()
{
// Check if submitted on an even minute.
if (!modSettings.openingTimeEnabled || (int) (BombInfo.GetTime() / 60) % 2 == 0)
if (!modSettings.OpeningTimeEnabled() || (int) (BombInfo.GetTime() / 60) % 2 == 0)
{
if (CurrentStage < MaxStages && CurrentFlavor == Solution[CurrentStage])
{
Expand Down Expand Up @@ -382,17 +402,23 @@ private IEnumerator SwitchScoop(int ix, bool activate)
}
}

public string TwitchHelpMessage = "Move left/right with “!{0} left” and “!{0} right”. Cycle the flavours with “!{0} cycle”. Sell the currently selected flavour with “!{0} sell“. Sell a specific flavour with “!{0} sell flavour”. Check the opening hours with “!{0} hours”.";
public string[] TwitchValidCommands = { "^(cycle|left|right|l|r|sell|submit|middle|s|m|hours)( .*)?" };
[NonSerialized] public string TwitchHelpMessage = "Move left/right with “!{0} left” and “!{0} right”. Cycle the flavours with “!{0} cycle”. Sell the currently selected flavour with “!{0} sell“. Sell a specific flavour with “!{0} sell flavour”. Check the opening hours with “!{0} hours”.";
[NonSerialized] public string[] TwitchValidCommands = { "^(cycle|left|right|l|r|sell|submit|middle|s|m|hours)( .*)?" };

public IEnumerator ProcessTwitchCommand(string command)
{
string[] pieces = command.Trim().ToLowerInvariant().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

if (pieces.Length > 1 && (pieces[0] == "submit" || pieces[0] == "sell" || pieces[0] == "middle" || pieces[0] == "s" || pieces[0] == "m"))
{
yield return null;
command = command.Substring(pieces[0].Length).Trim();
command = command.Substring(pieces[0].Length).Trim();
if (Flavours.All(x => !x.Name.StartsWith(command, StringComparison.InvariantCultureIgnoreCase)))
{
yield return string.Format("sendtochaterror I don't know of a flavour called {0}", command);
yield break;
}

yield return null;
string originalLabel = FlavourLabel.text;
do
{
Expand Down Expand Up @@ -422,7 +448,10 @@ public IEnumerator ProcessTwitchCommand(string command)
}
else if (pieces.Length == 1 && pieces[0] == "hours")
{
yield return "sendtochat " + (modSettings.openingTimeEnabled ? "We are open every other hour today." : "We're open all day today!");
if(modSettings.HoursCommandEnabled())
yield return "sendtochat " + (modSettings.OpeningTimeEnabled() ? "We are open every other hour today." : "We're open all day today!");
else
yield return "sendtochat Sorry, hours are currently unavailable. Enjoy your ice cream!";
}

var buttons = new List<KMSelectable>();
Expand Down
5 changes: 0 additions & 5 deletions Assets/IceCreamModule.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -1677,11 +1677,6 @@ MonoBehaviour:
- {fileID: 2100000, guid: 70b26619f487b5148af4c660372d376e, type: 2}
- {fileID: 2100000, guid: 5b134a82af3d70a4f9795ebe79b74525, type: 2}
- {fileID: 2100000, guid: 5b134a82af3d70a4f9795ebe79b74525, type: 2}
TwitchHelpMessage: Move left/right with !{0} left and !{0} right. Cycle the flavors
with !{0} cycle. Sell the currently selected flavour with !{0} sell. Sell a specific
flavour with !{0} sell flavour
TwitchValidCommands:
- ^(cycle|left|right|l|r|sell|submit|middle|s|m)( .*)?
--- !u!114 &114071382663949962
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down