-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
60 lines (45 loc) · 1.7 KB
/
Copy pathmain.py
File metadata and controls
60 lines (45 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- coding: utf-8 -*-
import sys
import os
from core.qt_compat import QApplication
from ui.main_window import MainWindow
from core.i18n import I18nManager
from core.resource_manager import ResourceManager
def _load_default_resources():
res_mgr = ResourceManager.instance()
base_dir = os.path.dirname(os.path.abspath(__file__))
pak_dir = os.path.join(base_dir, "pak")
if not os.path.isdir(pak_dir):
return
img_dir = os.path.join(pak_dir, "images")
if os.path.isdir(img_dir):
for fname in sorted(os.listdir(img_dir)):
if fname.lower().endswith((".png", ".jpg", ".bmp", ".gif", ".tga")):
name = os.path.splitext(fname)[0]
fpath = os.path.join("images", fname)
res_mgr.add_image(name, fpath)
font_dir = os.path.join(pak_dir, "data")
if os.path.isdir(font_dir):
for fname in sorted(os.listdir(font_dir)):
if fname.lower().endswith(".txt") and not fname.startswith("_"):
name = os.path.splitext(fname)[0]
fpath = os.path.join("data", fname)
res_mgr.add_font(name, fpath)
def main():
app = QApplication(sys.argv)
app.setApplicationName("SexyUIEditor")
app.setOrganizationName("StackAndPointer")
app.setApplicationVersion("1.2")
i18n = I18nManager.instance()
i18n.init_locale()
_load_default_resources()
window = MainWindow()
window.show()
# Handle command line arguments (file association)
if len(sys.argv) > 1:
file_path = sys.argv[1]
if file_path and os.path.exists(file_path):
window.load_project(file_path)
sys.exit(app.exec())
if __name__ == "__main__":
main()