Browse Source

Rudimentary game tracking

pull/92/head
Adam Johnson 7 years ago
parent
commit
3e7b22c344
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 3
      korman/operators/op_export.py
  2. 66
      korman/operators/op_world.py
  3. 1
      korman/properties/__init__.py
  4. 5
      korman/properties/modifiers/logic.py
  5. 33
      korman/properties/prop_world.py
  6. 37
      korman/ui/ui_world.py

3
korman/operators/op_export.py

@ -20,8 +20,7 @@ from pathlib import Path
import pstats
from .. import exporter
from ..properties.prop_world import PlasmaAge
from ..properties.modifiers.logic import game_versions
from ..properties.prop_world import PlasmaAge, game_versions
from ..korlib import ConsoleToggler
class ExportOperator(bpy.types.Operator):

66
korman/operators/op_world.py

@ -14,7 +14,8 @@
# along with Korman. If not, see <http://www.gnu.org/licenses/>.
import bpy
from bpy.props import *
from pathlib import Path
class AgeOperator:
@classmethod
@ -22,6 +23,69 @@ class AgeOperator:
return context.scene.render.engine == "PLASMA_GAME"
class GameAddOperator(AgeOperator, bpy.types.Operator):
bl_idname = "world.plasma_game_add"
bl_label = "Add Plasma Game"
filepath = StringProperty(subtype="DIR_PATH")
directory = BoolProperty(default=True, options={"HIDDEN"})
game_index = IntProperty(default=-1, options={"HIDDEN"})
def execute(self, context):
w = context.world
if w:
# First, verify this is a valid Uru directory...
path = Path(self.filepath)
if not path.is_dir():
self.report({"ERROR"}, "The selection is not a valid directory.")
return {"CANCELLED"}
if not ((path / "UruExplorer.exe").is_file() or (path / "plClient.exe").is_file()):
self.report({"ERROR"}, "The selected directory is not a copy of URU.")
return {"CANCELLED"}
# New game?
games = w.plasma_games
new_game = self.game_index == -1
if new_game:
games.active_game_index = len(games.games)
game = games.games.add()
else:
game = games.games[self.game_index]
# Setup game...
game.path = self.filepath
if (path / "cypython22.dll").is_file():
game.version = "pvPots"
else:
game.version = "pvMoul"
game.name = path.name
return {"FINISHED"}
else:
return {"CANCELLED"}
def invoke(self, context, event):
context.window_manager.fileselect_add(self)
return {"RUNNING_MODAL"}
class GameRemoveOperator(AgeOperator, bpy.types.Operator):
bl_idname = "world.plasma_game_remove"
bl_label = "Remove Plasma Game"
def execute(self, context):
w = context.world
if w:
games = w.plasma_games
if games.active_game_index >= len(games.games):
return {"CANCELLED"}
games.games.remove(games.active_game_index)
return {"FINISHED"}
else:
return {"CANCELLED"}
class PageAddOperator(AgeOperator, bpy.types.Operator):
bl_idname = "world.plasma_page_add"
bl_label = "Add Page"

1
korman/properties/__init__.py

@ -29,3 +29,4 @@ def register():
bpy.types.Texture.plasma_layer = bpy.props.PointerProperty(type=PlasmaLayer)
bpy.types.World.plasma_age = bpy.props.PointerProperty(type=PlasmaAge)
bpy.types.World.plasma_fni = bpy.props.PointerProperty(type=PlasmaFni)
bpy.types.World.plasma_games = bpy.props.PointerProperty(type=PlasmaGames)

5
korman/properties/modifiers/logic.py

@ -18,13 +18,10 @@ from bpy.props import *
from PyHSPlasma import *
from .base import PlasmaModifierProperties
from ..prop_world import game_versions
from ...exporter import ExportError
from ... import idprops
game_versions = [("pvPrime", "Ages Beyond Myst (63.11)", "Targets the original Uru (Live) game"),
("pvPots", "Path of the Shell (63.12)", "Targets the most recent offline expansion pack"),
("pvMoul", "Myst Online: Uru Live (70)", "Targets the most recent online game")]
class PlasmaVersionedNodeTree(idprops.IDPropMixin, bpy.types.PropertyGroup):
name = StringProperty(name="Name")
version = EnumProperty(name="Version",

33
korman/properties/prop_world.py

@ -17,6 +17,9 @@ import bpy
from bpy.props import *
from PyHSPlasma import *
game_versions = [("pvPrime", "Ages Beyond Myst (63.11)", "Targets the original Uru (Live) game"),
("pvPots", "Path of the Shell (63.12)", "Targets the most recent offline expansion pack"),
("pvMoul", "Myst Online: Uru Live (70)", "Targets the most recent online game")]
class PlasmaFni(bpy.types.PropertyGroup):
bl_idname = "world.plasma_fni"
@ -55,6 +58,36 @@ class PlasmaFni(bpy.types.PropertyGroup):
min=1)
class PlasmaGame(bpy.types.PropertyGroup):
name = StringProperty(name="Name",
description="Name of the Plasma Game",
options=set())
path = StringProperty(name="Path",
description="Path to this Plasma Game",
options=set())
version = EnumProperty(name="Version",
description="Plasma version of this game",
items=game_versions,
options=set())
class PlasmaGames(bpy.types.PropertyGroup):
bl_idname = "world.plasma_games"
games = CollectionProperty(type=PlasmaGame)
active_game_index = IntProperty(options={"HIDDEN"})
@property
def active_game(self):
if len(self.games) > self.active_game_index and self.active_game_index != -1:
return self.games[self.active_game_index]
return None
@property
def is_game_active(self):
return len(self.games) > 0 and self.active_game_index != -1
class PlasmaPage(bpy.types.PropertyGroup):
def _check_suffix(self, context):
"""Verifies that a suffix change does not conflict"""

37
korman/ui/ui_world.py

@ -26,6 +26,43 @@ class AgeButtonsPanel:
return context.world and context.scene.render.engine == "PLASMA_GAME"
class PlasmaGamePanel(AgeButtonsPanel, bpy.types.Panel):
bl_label = "Plasma Games"
def draw(self, context):
layout = self.layout
games = context.world.plasma_games
row = layout.row()
row.template_list("PlasmaGameList", "games", games, "games", games,
"active_game_index", rows=2)
col = row.column(align=True)
col.operator("world.plasma_game_add", icon="ZOOMIN", text="")
col.operator("world.plasma_game_remove", icon="ZOOMOUT", text="")
# Game Properties
active_game_index = games.active_game_index
if active_game_index < len(games.games):
active_game = games.games[active_game_index]
layout.separator()
box = layout.box()
box.prop(active_game, "path", emboss=False)
box.prop(active_game, "version")
box.separator()
row = box.row(align=True)
op = row.operator("world.plasma_game_add", icon="FILE_FOLDER", text="Change Path")
op.filepath = active_game.path
op.game_index = active_game_index
class PlasmaGameList(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_property, index=0, flt_flag=0):
layout.prop(item, "name", text="", emboss=False, icon="BOOKMARKS")
class PlasmaPageList(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_property, index=0, flt_flag=0):
layout.prop(item, "name", text="", emboss=False, icon="BOOKMARKS")

Loading…
Cancel
Save