Compare commits
No commits in common. "d344841a1a2ef41465100b13f3cef34722b9a36f" and "ea57844c33c2745265602902d97e56d262816acb" have entirely different histories.
d344841a1a
...
ea57844c33
9 changed files with 17 additions and 51 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -160,4 +160,3 @@ cython_debug/
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
conf/user*.json
|
|
|
@ -1,6 +1 @@
|
||||||
Various game configuration files go here
|
game configuration goes here
|
||||||
|
|
||||||
* `default.json` contains default settings for the game
|
|
||||||
* `user.json` contains modifications of those defaults made through the UI
|
|
||||||
|
|
||||||
`engine/config.py` is designed to read, write, manage and otherwise handle these files.
|
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"fullscreen": true
|
|
||||||
}
|
|
2
conf/init.json
Normal file
2
conf/init.json
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
{
|
||||||
|
}
|
|
@ -11,10 +11,8 @@ class SettingsLoader(UserDict):
|
||||||
self.reload()
|
self.reload()
|
||||||
|
|
||||||
def load_settings_file(self: object, file: str) -> None:
|
def load_settings_file(self: object, file: str) -> None:
|
||||||
if not data.exists('conf', file):
|
|
||||||
return
|
|
||||||
ext = os.path.splitext(file)[1]
|
ext = os.path.splitext(file)[1]
|
||||||
with data.fd_open('conf', file) as fd:
|
with data.data_open('conf', file) as fd:
|
||||||
if ext == '.json':
|
if ext == '.json':
|
||||||
self.data.update(json.load(fd))
|
self.data.update(json.load(fd))
|
||||||
else:
|
else:
|
||||||
|
@ -32,20 +30,6 @@ class SettingsMutable(SettingsLoader):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class SettingsWritable(SettingsMutable):
|
class SettingsWritable(SettingsMutable):
|
||||||
def __init__(self: object, files: list, outfile: str):
|
pass
|
||||||
super().__init__(files)
|
|
||||||
self.outfile = outfile
|
|
||||||
|
|
||||||
def save(self: object):
|
|
||||||
defaults = SettingsReadOnly([x for x in self.files if x != self.outfile])
|
|
||||||
outdata = {}
|
|
||||||
for k in self.data.keys():
|
|
||||||
if not k in defaults:
|
|
||||||
outdata[k] = self.data[k]
|
|
||||||
if outdata or data.exists('conf', self.outfile):
|
|
||||||
with data.fd_write('conf', self.outfile) as fd:
|
|
||||||
json.dump(outdata, fd, indent=4)
|
|
||||||
|
|
||||||
|
|
||||||
init = SettingsWritable(['default.json', 'user.json'], 'user.json')
|
|
||||||
|
|
||||||
|
init = SettingsWritable(['init.json'])
|
||||||
|
|
|
@ -10,15 +10,7 @@ def program_path() -> str:
|
||||||
|
|
||||||
return g_pp
|
return g_pp
|
||||||
|
|
||||||
def exists(vault: str, path: str) -> bool:
|
def data_open(vault: str, path: str) -> object:
|
||||||
fp = os.path.join(program_path(), vault, path)
|
|
||||||
return os.path.exists(fp)
|
|
||||||
|
|
||||||
def fd_open(vault: str, path: str) -> object:
|
|
||||||
fp = os.path.join(program_path(), vault, path)
|
fp = os.path.join(program_path(), vault, path)
|
||||||
return open(fp, 'r')
|
return open(fp, 'r')
|
||||||
|
|
||||||
def fd_write(vault: str, path: str) -> object:
|
|
||||||
fp = os.path.join(program_path(), vault, path)
|
|
||||||
os.makedirs(os.path.join(program_path(), vault), exist_ok=True)
|
|
||||||
return open(fp, 'w')
|
|
||||||
|
|
|
@ -44,11 +44,9 @@ def init_window() -> None:
|
||||||
# an available resolution
|
# an available resolution
|
||||||
pass
|
pass
|
||||||
|
|
||||||
display = pyglet.display.get_display()
|
display = pyglet.canvas.get_display()
|
||||||
screens = display.get_screens()
|
screens = display.get_screens()
|
||||||
windows = []
|
windows = []
|
||||||
# for screen in screens:
|
for screen in screens:
|
||||||
# print(f"creating window on screen {screen}")
|
windows.append(window.Window(fullscreen=True, screen=screen))
|
||||||
# windows.append(pyglet.window.Window(fullscreen=True, screen=screen))
|
window = pyglet.window.Window())
|
||||||
window = pyglet.window.Window(fullscreen=fs, screen=screens[0])
|
|
||||||
cfg.save()
|
|
|
@ -7,7 +7,6 @@ unittest.main(exit=False)
|
||||||
print("Hello!!!")
|
print("Hello!!!")
|
||||||
|
|
||||||
engine.screen.init_window()
|
engine.screen.init_window()
|
||||||
window = engine.screen.window
|
|
||||||
|
|
||||||
label = pyglet.text.Label('Hello, world',
|
label = pyglet.text.Label('Hello, world',
|
||||||
font_name='Times New Roman',
|
font_name='Times New Roman',
|
||||||
|
@ -15,7 +14,7 @@ label = pyglet.text.Label('Hello, world',
|
||||||
x=window.width//2, y=window.height//2,
|
x=window.width//2, y=window.height//2,
|
||||||
anchor_x='center', anchor_y='center')
|
anchor_x='center', anchor_y='center')
|
||||||
|
|
||||||
@window.event
|
@pyglet.window.event
|
||||||
def on_draw():
|
def on_draw():
|
||||||
engine.screen.window.clear()
|
engine.screen.window.clear()
|
||||||
label.draw()
|
label.draw()
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
patch
|
patch==1.16
|
||||||
pyglet
|
pyglet==2.0.10
|
||||||
unoconv
|
unoconv==0.9.0
|
||||||
|
|
Loading…
Add table
Reference in a new issue