From b37cca33c44b894e3a1da002bc20b19a85d29326 Mon Sep 17 00:00:00 2001 From: developomp Date: Sat, 12 Mar 2022 11:37:36 +0900 Subject: [PATCH] improved function naming --- CONTRIBUTING.md | 18 ++++++++++++++++ WBM/WBM.cs | 23 ++++++++++---------- WBM/features/clearChat.cs | 4 ++-- WBM/features/clearMessage.cs | 2 +- WBM/features/killStreakSFX.cs | 5 +++++ WBM/features/oldGunSound.cs | 32 ++++++++++++++-------------- WBM/features/playerStats.cs | 5 +++++ WBM/features/shiftToCrouch.cs | 6 ++++++ WBM/features/showEloOnLeaderboard.cs | 9 ++++++-- WBM/features/showSquadServer.cs | 9 ++++++-- WBM/features/showTestingServer.cs | 9 ++++++-- WBM/features/teamStats.cs | 5 +++++ WBM/features/weaponStats.cs | 5 +++++ 13 files changed, 95 insertions(+), 37 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..f4bc0e5 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,18 @@ +# Contribution guide + +## feature structure + +- All features should be contained in the `WBM/features` folder. + +### Feature functions + +- All features can have at most one function to be called in each event functions. +- feature function should have the following format: `` + + | Event function | feature function prefix | + | -------------: | :---------------------- | + | `Awake` | `init` | + | `Start` | `setup` | + | `Update` | `do` | + | `OnGUI` | `draw` | + | `onDestroy` | `destroy` | diff --git a/WBM/WBM.cs b/WBM/WBM.cs index 8a9f831..35912e0 100644 --- a/WBM/WBM.cs +++ b/WBM/WBM.cs @@ -29,7 +29,7 @@ namespace WBM this.setupOldGunSound(); this.setupWSSever(); - this.setupClearChatOnKeyPress(); + this.setupClearChat(); this.setupShiftToCrouch(); this.setupShowEloOnLeaderBoard(); this.setupShowSquadServer(); @@ -47,19 +47,18 @@ namespace WBM this.moveUIOnKeyPress(); this.resetUIOnKeyPress(); this.toggleUIOnKeyPress(); - this.toggleKillStreakSFXOnKeyPress(); - this.togglePlayerStatsOnKeyPress(); - this.toggleWeaponStatsOnKeyPress(); - this.toggleTeamStatsOnKeyPress(); - this.toggleLeaderboardEloOnKeyPress(); - this.toggleShowSquadServerOnKeyPress(); - this.toggleTestingServerOnKeyPress(); - this.clearChatOnKeyPress(); - this.clearDeathLogOnKeyPress(); + this.doKillStreakSFX(); + this.doPlayerStats(); + this.doWeaponStats(); + this.doTeamStats(); + this.doLeaderboardElo(); + this.doShowSquadServer(); + this.doTestingServer(); + this.doClearChat(); + this.doclearMessage(); this.showConfigOnKeyPress(); - this.toggleShiftToCrouchOnKeyPress(); - this.crouchOnKeyPress(); + this.doShiftToCrouch(); } /// Called multiple times per frame in response to GUI events. diff --git a/WBM/features/clearChat.cs b/WBM/features/clearChat.cs index 4410453..df045a2 100644 --- a/WBM/features/clearChat.cs +++ b/WBM/features/clearChat.cs @@ -12,13 +12,13 @@ namespace WBM private ConfigEntry clearChatShortcut; - private void setupClearChatOnKeyPress() + private void setupClearChat() { this.drawChatMessageFuncRef = webguyType.GetMethod("EBDKFEJMEMB", bindFlags); this.clearChatShortcut = Config.Bind("Hotkeys", "clear chat", new KeyboardShortcut(KeyCode.Z, KeyCode.RightShift)); } - private void clearChatOnKeyPress() + private void doClearChat() { if (this.clearChatShortcut.Value.IsDown()) this.clearChat(); } diff --git a/WBM/features/clearMessage.cs b/WBM/features/clearMessage.cs index da2e57e..d3295d7 100644 --- a/WBM/features/clearMessage.cs +++ b/WBM/features/clearMessage.cs @@ -6,7 +6,7 @@ namespace WBM { private ConfigEntry clearDeathLogShortcut; - private void clearDeathLogOnKeyPress() + private void doclearMessage() { if (this.clearDeathLogShortcut.Value.IsDown()) this.clearMessagesFuncRef.Invoke(this.webguy, new object[] { }); } diff --git a/WBM/features/killStreakSFX.cs b/WBM/features/killStreakSFX.cs index 605cdb9..e749c7e 100644 --- a/WBM/features/killStreakSFX.cs +++ b/WBM/features/killStreakSFX.cs @@ -29,6 +29,11 @@ namespace WBM this.killStreakSFXShortcut = Config.Bind("Hotkeys", "kill streak sound effect", new KeyboardShortcut(KeyCode.F, KeyCode.RightShift)); } + private void doKillStreakSFX() + { + this.toggleKillStreakSFXOnKeyPress(); + } + private void toggleKillStreakSFXOnKeyPress() { if (this.killStreakSFXShortcut.Value.IsDown()) this.killStreakSFX.Value = !this.killStreakSFX.Value; diff --git a/WBM/features/oldGunSound.cs b/WBM/features/oldGunSound.cs index 6c432f6..516ea02 100644 --- a/WBM/features/oldGunSound.cs +++ b/WBM/features/oldGunSound.cs @@ -49,7 +49,22 @@ namespace WBM } private AudioClip newSMGSound; - private void useOldGunSoundChanged(object sender, EventArgs e) + private void setupOldGunSound() + { + this.oldGunSoundRef = webguyType.GetField("PINGEJAHHDI", bindFlags); + this.AKSoundRef = webguyType.GetField("BJFBGCMEELH", bindFlags); + this.SMGSoundRef = webguyType.GetField("HKDDIMFIHCE", bindFlags); + + this.useOldGunSoundConf = Config.Bind("Config", "use old gun sound", true); + this.useOldGunSoundConf.SettingChanged += this.onOldGunSoundChange; + this.onOldGunSoundChange(new object(), new EventArgs()); + + this.oldGunSound = this.oldGunSoundRaw; + this.newAKSound = this.AKSoundRaw.ADCOCHNNCHM; + this.newSMGSound = this.SMGSoundRaw.ADCOCHNNCHM; + } + + private void onOldGunSoundChange(object sender, EventArgs e) { if (this.useOldGunSoundConf.Value) { @@ -62,20 +77,5 @@ namespace WBM this.SMGSoundRaw.ADCOCHNNCHM = this.newSMGSound; } } - - private void setupOldGunSound() - { - this.oldGunSoundRef = webguyType.GetField("PINGEJAHHDI", bindFlags); - this.AKSoundRef = webguyType.GetField("BJFBGCMEELH", bindFlags); - this.SMGSoundRef = webguyType.GetField("HKDDIMFIHCE", bindFlags); - - this.useOldGunSoundConf = Config.Bind("Config", "use old gun sound", true); - this.useOldGunSoundConf.SettingChanged += this.useOldGunSoundChanged; - this.useOldGunSoundChanged(new object(), new EventArgs()); - - this.oldGunSound = this.oldGunSoundRaw; - this.newAKSound = this.AKSoundRaw.ADCOCHNNCHM; - this.newSMGSound = this.SMGSoundRaw.ADCOCHNNCHM; - } } } diff --git a/WBM/features/playerStats.cs b/WBM/features/playerStats.cs index d99444c..438cf73 100644 --- a/WBM/features/playerStats.cs +++ b/WBM/features/playerStats.cs @@ -11,5 +11,10 @@ namespace WBM { if (this.showPlayerStatsShortcut.Value.IsDown()) this.showPlayerStats.Value = !this.showPlayerStats.Value; } + + private void doPlayerStats() + { + this.togglePlayerStatsOnKeyPress(); + } } } diff --git a/WBM/features/shiftToCrouch.cs b/WBM/features/shiftToCrouch.cs index 7bb1541..12a84fe 100644 --- a/WBM/features/shiftToCrouch.cs +++ b/WBM/features/shiftToCrouch.cs @@ -15,6 +15,12 @@ namespace WBM this.shiftToCrouchShortcut = Config.Bind("Hotkeys", "shift to crouch", new KeyboardShortcut(KeyCode.C, KeyCode.RightShift)); } + private void doShiftToCrouch() + { + this.crouchOnKeyPress(); + this.toggleShiftToCrouchOnKeyPress(); + } + private void crouchOnKeyPress() { // Skip if this setting is not activated diff --git a/WBM/features/showEloOnLeaderboard.cs b/WBM/features/showEloOnLeaderboard.cs index 6c5d5ba..529d3cd 100644 --- a/WBM/features/showEloOnLeaderboard.cs +++ b/WBM/features/showEloOnLeaderboard.cs @@ -30,17 +30,22 @@ namespace WBM this.showEloOnLeaderboardRef = webguyType.GetField("KDOBENAOLLF", bindFlags); this.showEloOnLeaderboard = Config.Bind("Config", "show Elo on leaderboard", true); - this.showEloOnLeaderboard.SettingChanged += this.onShowEloOnLeaderboardChanged; + this.showEloOnLeaderboard.SettingChanged += this.onShowEloOnLeaderboardChange; this.showEloOnLeaderboardShortcut = Config.Bind("Hotkeys", "show Elo on leaderboard", new KeyboardShortcut(KeyCode.E, KeyCode.RightShift)); this.showEloOnLeaderboardRaw = this.showEloOnLeaderboard.Value; } + private void doLeaderboardElo() + { + this.toggleLeaderboardEloOnKeyPress(); + } + private void toggleLeaderboardEloOnKeyPress() { if (this.showEloOnLeaderboardShortcut.Value.IsDown()) this.showEloOnLeaderboard.Value = !this.showEloOnLeaderboard.Value; } - private void onShowEloOnLeaderboardChanged(object sender, EventArgs e) + private void onShowEloOnLeaderboardChange(object sender, EventArgs e) { this.showEloOnLeaderboardRaw = this.showEloOnLeaderboard.Value; } diff --git a/WBM/features/showSquadServer.cs b/WBM/features/showSquadServer.cs index 28effe7..e734b08 100644 --- a/WBM/features/showSquadServer.cs +++ b/WBM/features/showSquadServer.cs @@ -30,17 +30,22 @@ namespace WBM this.showSquadServerRef = webguyType.GetField("PHPIBBCFKFI", bindFlags); this.showSquadServer = Config.Bind("Config", "show squad server", true); - this.showSquadServer.SettingChanged += this.onShowSquadServerChanged; + this.showSquadServer.SettingChanged += this.onShowSquadServerChange; this.showSquadServerShortcut = Config.Bind("Hotkeys", "show squad server", new KeyboardShortcut(KeyCode.S, KeyCode.RightShift)); this.showSquadServerRaw = this.showSquadServer.Value; } + private void doShowSquadServer() + { + this.toggleShowSquadServerOnKeyPress(); + } + private void toggleShowSquadServerOnKeyPress() { if (this.showSquadServerShortcut.Value.IsDown()) this.showSquadServer.Value = !this.showSquadServer.Value; } - private void onShowSquadServerChanged(object sender, EventArgs e) + private void onShowSquadServerChange(object sender, EventArgs e) { this.showSquadServerRaw = this.showSquadServer.Value; } diff --git a/WBM/features/showTestingServer.cs b/WBM/features/showTestingServer.cs index 16549b8..00f4b21 100644 --- a/WBM/features/showTestingServer.cs +++ b/WBM/features/showTestingServer.cs @@ -30,17 +30,22 @@ namespace WBM this.showTestingServerRef = webguyType.GetField("LHHEGFHLNJE", bindFlags); this.showTestingServer = Config.Bind("Config", "show testing server", true); - this.showTestingServer.SettingChanged += this.onShowTestingServerChanged; + this.showTestingServer.SettingChanged += this.onShowTestingServerChange; this.showTestingServerShortcut = Config.Bind("Hotkeys", "show testing server", new KeyboardShortcut(KeyCode.T, KeyCode.RightShift)); this.showTestingServerRaw = this.showTestingServer.Value; } + private void doTestingServer() + { + this.toggleTestingServerOnKeyPress(); + } + private void toggleTestingServerOnKeyPress() { if (this.showTestingServerShortcut.Value.IsDown()) this.showTestingServer.Value = !this.showTestingServer.Value; } - private void onShowTestingServerChanged(object sender, EventArgs e) + private void onShowTestingServerChange(object sender, EventArgs e) { this.showTestingServerRaw = this.showTestingServer.Value; } diff --git a/WBM/features/teamStats.cs b/WBM/features/teamStats.cs index 3fc7fa3..9625324 100644 --- a/WBM/features/teamStats.cs +++ b/WBM/features/teamStats.cs @@ -7,6 +7,11 @@ namespace WBM private ConfigEntry showTeamStats; private ConfigEntry showTeamStatsShortcut; + private void doTeamStats() + { + this.toggleTeamStatsOnKeyPress(); + } + private void toggleTeamStatsOnKeyPress() { if (this.showTeamStatsShortcut.Value.IsDown()) this.showTeamStats.Value = !this.showTeamStats.Value; diff --git a/WBM/features/weaponStats.cs b/WBM/features/weaponStats.cs index ac8e12d..5bf73e4 100644 --- a/WBM/features/weaponStats.cs +++ b/WBM/features/weaponStats.cs @@ -7,6 +7,11 @@ namespace WBM private ConfigEntry showWeaponStats; private ConfigEntry showWeaponStatsShortcut; + private void doWeaponStats() + { + this.toggleWeaponStatsOnKeyPress(); + } + private void toggleWeaponStatsOnKeyPress() { if (this.showWeaponStatsShortcut.Value.IsDown()) this.showWeaponStats.Value = !this.showWeaponStats.Value;