Skip to content

Commit c85b320

Browse files
committed
Popups when the ConversionRules folder or the JSON file(s) are missing.
1 parent 4cefa11 commit c85b320

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
<p align="center"><img src="media/cclmc-icon.png" alt="Legacy Mod Converter icon"></p>
1+
<p align="center"><img src="Media/cclmc-icon.png" alt="Legacy Mod Converter icon"></p>
22
<h1 align="center">Cortex Command Legacy Mod Converter</h1>
33

44
## Introduction
55
This project automates ***most*** of the conversion work required to convert the legacy (old) `Cortex Command` mods into `Cortex Command Community Project` compatible mods.
66

77
## Getting started
8-
Download the [***Legacy Mod Converter***](http://www.mediafire.com/file/1ncoydmaehf4nyn/Legacy_Mod_Converter.exe/file) program. Create a new folder and put your legacy mods that you want to convert in it. Run the Legacy Mod Converter program.
8+
Download the [***Legacy Mod Converter***](http://www.mediafire.com/file/ldp5p3l8pzocz3a/Legacy_Mod_Converter.exe/file) program. Create a new folder and put your legacy mods that you want to convert in it. Run the Legacy Mod Converter program.
99

1010
If you get a "`Microsoft Defender SmartScreen prevented an unrecognized app from starting. Running this app might put your PC at risk.`" popup message when trying to run the program you should press `More info` and then `Run anyway`.
1111

12-
<p align="center"><img src="media/cclmc-screenshot.png" alt="Legacy Mod Converter screenshot"></p>
12+
<p align="center"><img src="Media/cclmc-screenshot.png" alt="Legacy Mod Converter screenshot"></p>
1313

1414
## Disclaimer
1515
This program will do most of the conversion work for you, but some conversion steps are too hard to automate, so it's likely that `CCCP` will still crash or print errors in the console. If this happens you'll have to manually fix these issues in the legacy mod folder. If you want to properly fix these errors then you should download this repository and follow the instructions below so you can add your own conversion cases to `conversion_rules.py`.

main.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Run manually: python main.py
2-
3-
# Build exe not from spec: pyinstaller --noconsole --onefile --icon=Media/cclmc-icon.ico --add-data "Media/github-icon.png;Media" --add-data "Media/discord-icon.png;Media" --add-data "Media/finish.wav;Media" --name="Legacy Mod Converter" main.py
4-
# Build exe from spec (can be outdated): pyinstaller "Legacy Mod Converter.spec"
2+
# Build EXE for CCCP: pyinstaller --noconsole --onefile --icon=Media/cclmc-icon.ico --add-data="Media/github-icon.png;Media" --add-data="Media/discord-icon.png;Media" --add-data="Media/finish.wav;Media" --name="Legacy Mod Converter" main.py
53

64
from Python import gui
75

python/convert.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import os, time, shutil, math, re, sys, shutil, zipfile, json, pathlib
1+
import os, time, shutil, math, re, sys, shutil, zipfile, json, pathlib, webbrowser
22
from pathlib import Path
33
from jsoncomment import JsonComment
44
from playsound import playsound
5-
import PySimpleGUI as sg
65

76
from Python import shared_globals as cfg
87

@@ -29,8 +28,6 @@ def resource_path(relative_path):
2928
def load_conversion_rules():
3029
json_parser = JsonComment(json)
3130

32-
github_url = "https://github.com/cortex-command-community/Cortex-Command-Legacy-Mod-Converter"
33-
3431
json_files_found = 0
3532
try:
3633
for name in os.listdir("ConversionRules"):
@@ -40,14 +37,17 @@ def load_conversion_rules():
4037
json_files_found += 1
4138
conversion_rules.update(json_parser.load(f))
4239
except:
43-
sg.Popup("The folder 'ConversionRules' wasn't found next to this executable. You can get the missing folder from the Legacy Mod Converter GitHub repo:", github_url)
44-
sys.exit()
40+
check_github_button_clicked_and_exit(cfg.sg.Popup("The 'ConversionRules' folder wasn't found next to this executable. You can get the missing folder from the Legacy Mod Converter GitHub repo.", title="Missing ConversionRules folder", custom_text="Go to GitHub"))
4541

4642
if json_files_found == 0:
47-
sg.Popup("The folder 'ConversionRules' didn't contain any JSON files. You can get the JSON files from the Legacy Mod Converter GitHub repo:", github_url)
48-
sys.exit()
43+
check_github_button_clicked_and_exit(cfg.sg.Popup("The 'ConversionRules' folder didn't contain any JSON files. You can get the JSON files from the Legacy Mod Converter GitHub repo.", title="Missing JSON files", custom_text="Go to GitHub"))
44+
45+
4946

50-
load_conversion_rules()
47+
def check_github_button_clicked_and_exit(clicked_github_button):
48+
if clicked_github_button:
49+
webbrowser.open("https://github.com/cortex-command-community/Cortex-Command-Legacy-Mod-Converter")
50+
sys.exit()
5151

5252

5353
def convert():

python/gui.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ def init_window():
4646
]
4747
], title="Convert Mods")]
4848
]
49+
50+
play_finish_sound_setting = sg.user_settings_get_entry("play_finish_sound")
51+
sg.user_settings_set_entry("play_finish_sound", True if play_finish_sound_setting == None else play_finish_sound_setting)
4952

5053
options_column = [
5154
[sg.Frame(layout=[
@@ -59,8 +62,8 @@ def init_window():
5962
info_column = [
6063
[sg.Frame(layout=[
6164
[
62-
sg.Image(resource_path("media/github-icon.png"), enable_events=True, key="-GITHUB-", tooltip=" Visit this program's GitHub page ", size=(0, 30)),
63-
sg.Image(resource_path("media/discord-icon.png"), enable_events=True, key="-DISCORD-", tooltip=" Visit the CCCP Discord server for help ", size=(0, 30))
65+
sg.Image(resource_path("Media/github-icon.png"), enable_events=True, key="-GITHUB-", tooltip=" Visit this program's GitHub page ", size=(0, 30)),
66+
sg.Image(resource_path("Media/discord-icon.png"), enable_events=True, key="-DISCORD-", tooltip=" Visit the CCCP Discord server for help ", size=(0, 30))
6467
]
6568
], title="", pad=((9, 0), (8, 0)))]
6669
]
@@ -76,7 +79,9 @@ def init_window():
7679
]
7780

7881
cfg.sg = sg
79-
window = sg.Window("Legacy Mod Converter - v1.0", layout, icon=resource_path("media/cclmc-icon.ico"), button_color=(sg.theme_text_color(), "#2a3948"))
82+
convert.load_conversion_rules()
83+
84+
window = sg.Window("Legacy Mod Converter - v1.0", layout, icon=resource_path("Media/cclmc-icon.ico"), button_color=(sg.theme_text_color(), "#2a3948"))
8085
cfg.progress_bar = window["-PROGRESS BAR-"]
8186

8287
return window

0 commit comments

Comments
 (0)