57 lines
1.4 KiB
Python
Executable File
57 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import sys
|
|
from PyQt5.QtWidgets import (
|
|
QApplication, QVBoxLayout, QPushButton,
|
|
QDialog
|
|
)
|
|
from OpenGL.GL import *
|
|
from OpenGL.GLU import *
|
|
from editortool.maptool import MapWindow
|
|
from editortool.langtool import LangToolWindow
|
|
from editortool.cutscenetool import CutsceneToolWindow
|
|
|
|
DEFAULT_TOOL = None
|
|
DEFAULT_TOOL = "map"
|
|
|
|
TOOLS = [
|
|
("Map Editor", "map", MapWindow),
|
|
("Language Editor", "language", LangToolWindow),
|
|
("Cutscene Editor", "cutscene", CutsceneToolWindow),
|
|
]
|
|
|
|
class EditorChoiceDialog(QDialog):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.setWindowTitle("Choose Tool")
|
|
layout = QVBoxLayout(self)
|
|
self.selected = None
|
|
for label, key, win_cls in TOOLS:
|
|
btn = QPushButton(label)
|
|
btn.clicked.connect(lambda checked, w=win_cls: self.choose_tool(w))
|
|
layout.addWidget(btn)
|
|
|
|
def choose_tool(self, win_cls):
|
|
self.selected = win_cls
|
|
self.accept()
|
|
|
|
def get_choice(self):
|
|
return self.selected
|
|
|
|
def main():
|
|
app = QApplication(sys.argv)
|
|
tool_map = { key: win_cls for _, key, win_cls in TOOLS }
|
|
if DEFAULT_TOOL in tool_map:
|
|
win_cls = tool_map[DEFAULT_TOOL]
|
|
else:
|
|
choice_dialog = EditorChoiceDialog()
|
|
if choice_dialog.exec_() == QDialog.Accepted:
|
|
win_cls = choice_dialog.get_choice()
|
|
else:
|
|
sys.exit(0)
|
|
win = win_cls()
|
|
win.show()
|
|
sys.exit(app.exec_())
|
|
|
|
if __name__ == "__main__":
|
|
main()
|