mirror of https://github.com/ksherlock/prez.git
Compare commits
2 Commits
3887146361
...
62c070fb1a
Author | SHA1 | Date |
---|---|---|
Kelvin Sherlock | 62c070fb1a | |
Kelvin Sherlock | a8523f5ebd |
14
README.md
14
README.md
|
@ -3,6 +3,20 @@ iigs resource compiler
|
|||
|
||||
An experimental alternative to rez.
|
||||
|
||||
Usage:
|
||||
|
||||
```
|
||||
prez [options] file....
|
||||
```
|
||||
|
||||
Options:
|
||||
|
||||
* `--hex`: generate rez data statements
|
||||
* `--rez`: generate rez resource statements
|
||||
* `--data-fork`: save resource fork to a data fork (only win32/macos can generate a resource fork)
|
||||
* `-o file`: output file
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
|
||||
rComment("""
|
||||
FROTZ V2.55
|
||||
An interpreter for all Infocom and other Z-Machine games.
|
||||
Complies with the Z-Machine Standard version 1.1.
|
||||
|
||||
Originally written by Stefan Jokisch in 1995-1997.
|
||||
Ported to Unix by Galen Hazelwood.
|
||||
Reference code Unix and DOS ports are maintained by David Griffith.
|
||||
IIgs .console port by Kelvin Sherlock.
|
||||
|
||||
Frotz is free software; you can redistribute it and/or modify it \
|
||||
under the terms of the GNU General Public License as published by \
|
||||
the Free Software Foundation; either version 2 of the License, or \
|
||||
(at your option) any later version.
|
||||
""")
|
||||
|
||||
|
||||
rVersion( '0.0.0a2', verUS, "Frotz 2.55", "Kelvin Sherlock\nDavid Griffith, et alia")
|
||||
|
||||
rToolStartup(
|
||||
mode640 | fFastPortAware | fUseShadowing,
|
||||
3, (4, 0x0308), 5, 6, 11, 14, 15, 16, 18, 20, 21, 22, 23, 27, 28, 30,
|
||||
export="kStartStop"
|
||||
)
|
||||
|
||||
rMenuBar(
|
||||
rMenu("@",
|
||||
rMenuItem("About Frotz…", export="kAboutMenuItem"),
|
||||
rMenuItem("Preferences…", ",", export="kPreferencesMenuItem"),
|
||||
DividerMenuItem(),
|
||||
export="kAppleMenu"
|
||||
),
|
||||
rMenu(" File ",
|
||||
# rMenuItem("New ", "Nn", export="kNewMenuItem"),
|
||||
rMenuItem("Open…", "Oo", export="kOpenMenuItem"),
|
||||
rMenuItem("Restart", "Rr", export="kRestartMenuItem"),
|
||||
# rMenuItem("Save", "Ss", disabled=True, export="kSaveMenuItem"),
|
||||
# DividerMenuItem(),
|
||||
# rMenuItem("Close", "Ww", id=0xff, export="kCloseMenuItem"),
|
||||
DividerMenuItem(),
|
||||
rMenuItem("Quit", "Qq", export="kQuitMenuItem"),
|
||||
export = "kFileMenu"
|
||||
),
|
||||
rMenu(" Edit ",
|
||||
UndoMenuItem(), # shortcut for doing it manually,
|
||||
DividerMenuItem(),
|
||||
CutMenuItem(),
|
||||
CopyMenuItem(),
|
||||
PasteMenuItem(),
|
||||
ClearMenuItem(),
|
||||
export = "kEditMenu"
|
||||
),
|
||||
export = "kMenuBar"
|
||||
)
|
||||
|
||||
AboutRect = rect(x = 0, y = 0, height = 100, width = 400)
|
||||
|
||||
rWindParam1(
|
||||
|
||||
AboutRect.center(), None,
|
||||
|
||||
rStatTextControl(
|
||||
|
||||
AboutRect,
|
||||
|
||||
rTextForLETextBox2(
|
||||
TBCenterJust,
|
||||
TBFont, TBVenice, b"\x00", b"\x18", # Venice 24-point
|
||||
"Frotz",
|
||||
TBFont, TBMonaco, b"\x00", b"\x09", # monaco, 9-point
|
||||
"\nv 2.55\n",
|
||||
"Stefan Jokisch, Galen Hazel, David Griffith, et alia\n",
|
||||
"IIgs version by Kelvin Sherlock (alpha 2)"
|
||||
)
|
||||
|
||||
),
|
||||
|
||||
frameBits = fVis,
|
||||
export = "kAboutWindow"
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# this exists so we can "python3 prez.py" while developing.
|
||||
|
||||
if __name__ == '__main__':
|
||||
from prez.cli import main
|
||||
main()
|
|
@ -1,12 +1,11 @@
|
|||
import struct
|
||||
from bisect import bisect_left
|
||||
from rect import *
|
||||
from utils import *
|
||||
import sys
|
||||
from bisect import bisect_left
|
||||
|
||||
from resource_writer import ResourceWriter
|
||||
|
||||
from constants import *
|
||||
from . rect import *
|
||||
from . utils import *
|
||||
from . resource_writer import ResourceWriter
|
||||
from . constants import *
|
||||
|
||||
__all__ = ["rObject", "rText", "rTextBlock", "rTextForLETextBox2",
|
||||
"rAlertString", "rErrorString", "rComment", "rPString",
|
|
@ -3,10 +3,12 @@ import sys
|
|||
import io
|
||||
import argparse
|
||||
import time
|
||||
from open_rfork import open_rfork
|
||||
import traceback
|
||||
import importlib
|
||||
|
||||
from . open_rfork import open_rfork
|
||||
from . base import rObject
|
||||
|
||||
from base import rObject
|
||||
|
||||
# from base import *
|
||||
# from window import *
|
||||
|
@ -19,20 +21,21 @@ from base import rObject
|
|||
def rez_scope():
|
||||
# import all the resource types and constants into
|
||||
# a dictionary to be the exec() local scope
|
||||
import base
|
||||
import window
|
||||
import control
|
||||
import menu
|
||||
import sound
|
||||
import rect
|
||||
import version
|
||||
import tool_startup
|
||||
import icon
|
||||
import constants
|
||||
# import prez.base
|
||||
# import prez.window
|
||||
# import prez.control
|
||||
# import prez.menu
|
||||
# import prez.sound
|
||||
# import prez.rect
|
||||
# import prez.version
|
||||
# import prez.tool_startup
|
||||
# import prez.icon
|
||||
# import prez.constants
|
||||
|
||||
# could do: mod = importlib.import_module("base"), etc.
|
||||
scope = {}
|
||||
for mod in (base, window, control, menu, sound, rect, version, tool_startup, icon, constants):
|
||||
for m in ('base', 'window', 'control', 'menu', 'sound', 'rect', 'version', 'tool_startup', 'icon', 'constants'):
|
||||
mod = importlib.import_module('.' + m, 'prez')
|
||||
if hasattr(mod, '__all__'): keys = mod.__all__
|
||||
else: keys = [x for x in dir(mod) if x[0] != '_']
|
||||
|
||||
|
@ -56,20 +59,20 @@ def execute(filename, scope):
|
|||
print(traceback.format_exc())
|
||||
return False
|
||||
|
||||
if __name__ == '__main__':
|
||||
def main():
|
||||
|
||||
p = argparse.ArgumentParser(prog='prez')
|
||||
p.add_argument('files', metavar='file', type=str, nargs='+')
|
||||
p.add_argument('--rez', action='store_true', help="Generate REZ code")
|
||||
p.add_argument('-x', action="store_true", help="Generate REZ data")
|
||||
p.add_argument('--hex', action="store_true", help="Generate REZ data")
|
||||
|
||||
p.add_argument('-D', type=str, nargs='+', help='define a variable')
|
||||
p.add_argument('--df', action="store_true", help="Write to a regular file")
|
||||
p.add_argument('--data-fork', action="store_true", help="Write to a regular file")
|
||||
p.add_argument('-o', metavar='file', type=str, help="Specify output file")
|
||||
|
||||
opts = p.parse_args()
|
||||
|
||||
|
||||
df = opts.df or not sys.platform in ("win32", "darwin")
|
||||
opts.data_fork = opts.data_fork or not sys.platform in ("win32", "darwin")
|
||||
|
||||
|
||||
scope = rez_scope()
|
||||
|
@ -81,19 +84,20 @@ if __name__ == '__main__':
|
|||
if errors > 0 : sys.exit(1)
|
||||
|
||||
if not opts.o: opts.rez = True
|
||||
if opts.x: opts.rez = True
|
||||
|
||||
if df or opts.rez:
|
||||
open_rfork = io.open
|
||||
|
||||
if opts.rez:
|
||||
if opts.rez or opts.hex:
|
||||
print("/* Generated on {} */".format(time.ctime()))
|
||||
print('#include "types.rez"\n')
|
||||
if opts.x: rObject.dump_hex()
|
||||
if opts.hex: rObject.dump_hex()
|
||||
else: rObject.dump_rez()
|
||||
else:
|
||||
with open_rfork(opts.o, "wb") as io:
|
||||
rObject.save_resources(io)
|
||||
opener = open_rfork
|
||||
if opts.data_fork: opener = io.open
|
||||
with opener(opts.o, "wb") as f:
|
||||
rObject.save_resources(f)
|
||||
|
||||
rObject.dump_exports()
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,8 +1,9 @@
|
|||
from base import rObject, rList, rPString, rTextForLETextBox2
|
||||
import struct
|
||||
from rect import *
|
||||
from colors import *
|
||||
from utils import *
|
||||
|
||||
from . base import rObject, rList, rPString, rTextForLETextBox2
|
||||
from . rect import *
|
||||
from . colors import *
|
||||
from . utils import *
|
||||
|
||||
|
||||
__all__ = [
|
|
@ -1,6 +1,7 @@
|
|||
from base import rObject
|
||||
import struct
|
||||
|
||||
from . base import rObject
|
||||
|
||||
|
||||
__all__ = ["rIcon"]
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
# key equivalants
|
||||
import enum
|
||||
from utils import *
|
||||
import struct
|
||||
|
||||
from . utils import *
|
||||
|
||||
__all__ = ["KeyEquivalent"]
|
||||
|
||||
def export_enum(cls):
|
|
@ -1,10 +1,11 @@
|
|||
|
||||
from base import *
|
||||
from utils import *
|
||||
from icon import rIcon
|
||||
import struct
|
||||
import enum
|
||||
|
||||
from . base import *
|
||||
from . utils import *
|
||||
from . icon import rIcon
|
||||
|
||||
|
||||
__all__ = [
|
||||
'rMenuBar',
|
||||
'rMenu',
|
|
@ -104,7 +104,7 @@ class size_class:
|
|||
self.width = 0
|
||||
|
||||
if len(args) == 2:
|
||||
self.height, self.width = args
|
||||
self._assign(*args)
|
||||
return
|
||||
|
||||
if len(args) == 1:
|
||||
|
@ -115,7 +115,7 @@ class size_class:
|
|||
return
|
||||
|
||||
if is_listy(other) and len(other) == 2:
|
||||
self.height, self.width = other
|
||||
self._assign(*other)
|
||||
return
|
||||
|
||||
if not args:
|
||||
|
@ -126,9 +126,22 @@ class size_class:
|
|||
|
||||
raise ValueError("bad size parameter")
|
||||
|
||||
def _assign(self, height, width):
|
||||
self.height = height
|
||||
self.width = width
|
||||
|
||||
def __eq__(self, other):
|
||||
return type(other) == size_class and self.height == other.height and self.width == other.width
|
||||
|
||||
def __str__(self):
|
||||
return "{{ {:d}, {:d} }}".format(self.height, self.width)
|
||||
|
||||
def __bytes__(self):
|
||||
return struct.pack("2H", self.height, self.width)
|
||||
|
||||
def __iter__(self):
|
||||
return (self.height, self.width).__iter__()
|
||||
|
||||
|
||||
def old_size(*args, height=None, width=None):
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
from base import rObject
|
||||
import audioop
|
||||
import struct
|
||||
import re
|
||||
|
@ -7,6 +5,8 @@ import sys
|
|||
import os
|
||||
from math import log2
|
||||
|
||||
from . base import rObject
|
||||
|
||||
__all__ = ["rSoundSample"]
|
||||
|
||||
# See: IIgs TechNote #76 Miscellaneous Resource Formats
|
|
@ -1,9 +1,10 @@
|
|||
|
||||
from base import rObject
|
||||
from utils import *
|
||||
import enum
|
||||
import struct
|
||||
|
||||
from . base import rObject
|
||||
from . utils import *
|
||||
|
||||
|
||||
__all__ = ["rToolStartup"]
|
||||
|
||||
# can't be in utils since that's a different __all__
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
from base import rObject
|
||||
from utils import *
|
||||
import enum
|
||||
import struct
|
||||
import re
|
||||
|
||||
from . base import rObject
|
||||
from . utils import *
|
||||
|
||||
__all__ = ["rVersion"]
|
||||
|
||||
|
|
@ -1,13 +1,12 @@
|
|||
from base import *
|
||||
from control import rControlTemplate, rControlList
|
||||
from utils import *
|
||||
|
||||
import struct
|
||||
|
||||
from . base import *
|
||||
from . control import rControlTemplate, rControlList
|
||||
from . utils import *
|
||||
|
||||
|
||||
__all__ = ['rWindParam1']
|
||||
|
||||
|
||||
|
||||
fHilited = 0x0001
|
||||
fZoomed = 0x0002
|
||||
fAllocated = 0x0004
|
||||
|
@ -37,7 +36,6 @@ class rWindParam1(rObject):
|
|||
rType = 0x800e
|
||||
|
||||
def __init__(self, position, title=None, *controls,
|
||||
|
||||
frameBits = 0,
|
||||
refCon = 0,
|
||||
zoomRect = (0, 0, 0, 0),
|
Loading…
Reference in New Issue