Browse Source

Port to CS2

kiwec 5 tháng trước cách đây
mục cha
commit
692a13adcc
7 tập tin đã thay đổi với 26 bổ sung25 xóa
  1. 1 1
      .python-version
  2. 9 9
      README.md
  3. 5 5
      build.py
  4. 0 0
      gamestate_integration_cqs.cfg
  5. 3 3
      main.py
  6. 3 3
      setup.py
  7. 5 4
      state.py

+ 1 - 1
.python-version

@@ -1 +1 @@
-3.7.5
+3.10.5

+ 9 - 9
README.md

@@ -1,20 +1,18 @@
-# csgo-quake-sounds
+# cs2-quake-sounds
 
-Custom sounds in your Counter-Strike : Global Offensive matches.
-
-[Download](https://github.com/kiwec/csgo-quake-sounds/releases/latest)
+Custom sounds in your CS2 matches.
 
 ### FAQ
 
-* Does it work in matchmaking ? On faceit ?
+* Does it work in matchmaking? In premier? On faceit?
 
 Yes.
 
-* Will I get banned for using this ?
+* Will I get banned for using this?
 
 No. This is using [Game State Integration](https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Game_State_Integration), which is allowed by Valve.
 
-* How do I add my own sounds ?
+* How do I add my own sounds?
 
 Drop your sounds in the corresponding `sounds` folder. Feel free to remove the ones you don't like, too.
 
@@ -22,11 +20,13 @@ Please keep in mind that only OPUS files are supported.
 
 ### Running
 
-You probably want to use the [installer](https://github.com/kiwec/csgo-quake-sounds/releases/latest).
+You probably want to use the installer.
 
 However, if you want to try the latest version, execute these commands :
 
-* `git clone https://github.com/kiwec/csgo-quake-sounds.git && cd csgo-quake-sounds`
+* `git clone https://git.kiwec.net/kiwec/cs2-quake-sounds.git && cd cs2-quake-sounds`
+
+* `pip install cython numpy Pillow requests six` # wxasync build bullshit
 
 * `python setup.py install --user`
 

+ 5 - 5
build.py

@@ -7,7 +7,7 @@ buildOptions: Dict = dict(
     excludes=["tkinter"],
     include_files=[
         "sounds",
-        "gamestate_integration_ccs.cfg",
+        "gamestate_integration_cqs.cfg",
         "icon.ico",
         "config.ini",
     ],
@@ -17,12 +17,12 @@ buildOptions: Dict = dict(
 
 base = "Win32GUI" if sys.platform == "win32" else None
 
-executables = [Executable("main.py", base=base, targetName="csgo-custom-sounds.exe")]
+executables = [Executable("main.py", base=base)]
 
 setup(
-    name="csgo-custom-sounds",
-    version="1.5.2",
-    description="Play custom sounds via Gamestate Integration",
+    name="cs2-quake-sounds",
+    version="2.0.0",
+    description="Play quake sounds via Gamestate Integration",
     options=dict(build_exe=buildOptions),
     executables=executables,
 )

+ 0 - 0
gamestate_integration_ccs.cfg → gamestate_integration_cqs.cfg


+ 3 - 3
main.py

@@ -69,15 +69,15 @@ async def main():
     csgo_dir = get_csgo_path(os.path.join(get_steam_path(), "steamapps"))
     if csgo_dir is not None:
         copyfile(
-            "gamestate_integration_ccs.cfg",
-            os.path.join(csgo_dir, "csgo", "cfg", "gamestate_integration_ccs.cfg"),
+            "gamestate_integration_cqs.cfg",
+            os.path.join(csgo_dir, "game", "csgo", "cfg", "gamestate_integration_cqs.cfg"),
         )
 
     oalInit()
     app = WxAsyncApp()
     gui.MainFrame(
         None,
-        title="CSGO Custom Sounds",
+        title="CS2 Quake Sounds",
         size=wx.Size(320, 230),
         style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX),
     )

+ 3 - 3
setup.py

@@ -5,9 +5,9 @@ except ImportError:
     from distutils.core import setup
 
 setup(
-    name="csgo-custom-sounds",
-    version="1.5.2",
-    description="Play custom sounds via Gamestate Integration",
+    name="cs2-custom-sounds",
+    version="2.0.0",
+    description="Play quake sounds via Gamestate Integration",
     python_requires="==3.*,>=3.7.0",
     author="kiwec",
     license="UNLICENSE",

+ 5 - 4
state.py

@@ -1,4 +1,5 @@
 """Related to CSGO Gamestate"""
+import asyncio
 import json
 from threading import Lock, Thread
 from http.server import BaseHTTPRequestHandler, HTTPServer
@@ -83,7 +84,7 @@ class PlayerState:
 
         self.valid = True
 
-    def compare(self, old_state) -> None:
+    async def compare(self, old_state) -> None:
         # Init state without playing sounds
         if not old_state or not old_state.valid:
             return
@@ -197,11 +198,11 @@ class CSGOState:
                 return False
         return True
 
-    def update(self, json):
+    async def update(self, json):
         """Update the entire game state"""
         with self.lock:
             newstate = PlayerState(json, self.client.sounds)
-            newstate.compare(self.old_state)
+            await newstate.compare(self.old_state)
             self.old_state = newstate
 
 
@@ -211,7 +212,7 @@ class PostHandler(BaseHTTPRequestHandler):
         body = self.rfile.read(content_len)
         self.send_response(200)
         self.end_headers()
-        self.state.update(json.loads(body))
+        asyncio.run(self.state.update(json.loads(body)))
         return
 
     def log_message(self, format, *args):