summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-12-23 19:27:27 -0300
committerJesusaves <cpntb1@ymail.com>2020-12-23 19:27:27 -0300
commit3bf6ffd35f0dcc16f5cb6b20359be5fa09b521b6 (patch)
treeb89532fc634791d13ce0de94e17ddf7105fdfac4
parente919c27e7e150a3604a9b5804ed00f259607c553 (diff)
downloadsdk-3bf6ffd35f0dcc16f5cb6b20359be5fa09b521b6.tar.gz
sdk-3bf6ffd35f0dcc16f5cb6b20359be5fa09b521b6.tar.bz2
sdk-3bf6ffd35f0dcc16f5cb6b20359be5fa09b521b6.tar.xz
sdk-3bf6ffd35f0dcc16f5cb6b20359be5fa09b521b6.zip
Sketch for unit editor (read only)
-rw-r--r--script.rpy8
-rw-r--r--ueditor.rpy292
2 files changed, 300 insertions, 0 deletions
diff --git a/script.rpy b/script.rpy
index 9adf878..807b34b 100644
--- a/script.rpy
+++ b/script.rpy
@@ -10,6 +10,8 @@ label loop:
menu:
"Quest editor":
jump quest_editors
+ "Units editor":
+ jump units_editors
"Quit":
return
@@ -23,6 +25,12 @@ label restore:
f=open(get_path("quests.json"), "w")
json.dump(alltquests, f, indent=1, separators=(',', ': '))
f.close()
+ f=open(get_path("units.editor.json"), "r")
+ allunitsbase=json.load(f)
+ f.close()
+ f=open(get_path("units.json"), "w")
+ json.dump(allunitsbase, f, indent=1, separators=(',', ': '))
+ f.close()
pass
"Continue editing":
pass
diff --git a/ueditor.rpy b/ueditor.rpy
new file mode 100644
index 0000000..4c904af
--- /dev/null
+++ b/ueditor.rpy
@@ -0,0 +1,292 @@
+########################################################################################
+# This file is part of Spheres.
+# Copyright (C) 2019 Jesusalva
+
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+########################################################################################
+# Editor labels for developers
+screen units_editor():
+ modal True
+ frame:
+ background Frame("gui/frame.png", 0, 0)
+ xalign 0.5
+ yalign 0.5
+ ymargin 15
+ ypadding 10
+ xmargin 10
+
+ hbox:
+ spacing 30
+ xmaximum 0.85
+ ymaximum 0.85
+
+ # Navigation
+ viewport:
+ #child_size (350, 1000)
+ mousewheel True
+ draggable True
+ pagekeys True
+ xfill False
+ xmaximum 350
+ scrollbars "vertical"
+
+ vbox:
+ spacing 2
+ label _("Unit list")
+ $i=0
+ for entry in allunitsbase:
+ textbutton "{size=18}"+_("%d - %s" % (entry["unit_id"], entry["name"]))+"{/size}" action SetVariable("current", i)
+ $i+=1
+ $del i
+
+ # News screen
+ viewport:
+ #child_size (0.4, 0.8)
+ mousewheel True
+ #draggable True
+ #arrowkeys True
+ xfill False
+ scrollbars "vertical"
+
+ vbox:
+ xalign 0.5
+ spacing 20
+
+ $ uedit=allunitsbase[current]
+
+ label _("%d - %s %s %s" % (uedit["unit_id"], star_write(uedit["rare"]), uedit["name"], ifte(uedit["sex"], "(F)", "(M)")))
+ hbox:
+ spacing 10
+ textbutton _("-") action Function(ueditor, "unit_id", -1)
+ label ("%d" % uedit["unit_id"])
+ textbutton _("+") action Function(ueditor, "unit_id", 1)
+ null height 25
+ label _("Base ID %d" % uedit["unit_base_id"])
+ label _("Flavor text:")
+ label _(uedit["flavor"])
+ null height 25
+
+ label _("HP %d" % uedit["hp"])
+ label _("ATK %d" % uedit["strength"])
+ label _("Max Lv. %d" % uedit["max_level"])
+ null height 25
+
+ label _("Attribute %d" % uedit["attribute"])
+ label _("Job %d" % uedit["job"])
+ label _("Flags %d" % uedit["flags"])
+ null height 25
+
+ label _(".:: Active Skill ::.")
+ label _("ID %d" % uedit["skill_id"])
+ # TODO: Open skills.json and parse the IDs
+ null height 25
+
+ label _(".:: Passive ::.")
+ label _("ID %d" % uedit["ability_id"])
+ # TODO: Open skills.json and parse the IDs
+ null height 25
+
+ # TODO: Loot, waves
+ ###########################################
+ null height 40
+ hbox:
+ spacing 25
+
+ textbutton _("Save") action Function(ueditor_save)
+
+ textbutton _("Close") action Return()
+ textbutton _("New Quest") action Function(ueditor_new)
+ textbutton _("New S.") action Function(ueditor_new, 1)
+
+ ## Right-click and escape refresh screen
+ key "game_menu" action Function(RestartInteraction)#Return()
+ key "K_RETURN" action Function(RestartInteraction)#Return()
+
+init python:
+ import json, copy
+ def RestartInteraction():
+ renpy.restart_interaction()
+ return
+
+
+ def ueditor(key, operation, override=False):
+ global uedit
+ uedit=allunitsbase[current]
+ print str(uedit["unit_id"])
+ if override:
+ uedit[key]=operation
+ else:
+ uedit[key]+=operation
+ return
+
+ def ueditor_save():
+ global allunitsbase
+ f=open(get_path("units.editor.json"), "w")
+ json.dump(allunitsbase, f, indent=4, separators=(',', ': '))
+ f.close()
+ renpy.notify("File saved as units.editor.json")
+ return
+
+ def ueditor_new(special=False):
+ global allunitsbase
+ if not special:
+ qeid=len(allunitsbase)
+ qefl=1
+ qec=1
+ else:
+ qeid=90000
+ qefl=4
+ qec=20
+
+ allunitsbase.append({
+ "unit_id": qeid,
+ "difficulty": 0,
+ "requeriment": 0,
+ "cost": qec,
+ "flags": qefl,
+ "loot": [
+ ["1010", 1000],
+ ["1020", 100],
+ ["1030", 10]
+ ],
+ "waves": []})
+ renpy.notify("New units added: %d" % qeid)
+ return
+
+ def ueditor_addloot():
+ global uedit
+ uedit=allunitsbase[current]
+ uedit["loot"].append(["1000", 0])
+ renpy.notify("Added new loot field id 1000 (an invalid ID)")
+ return
+
+ def ueditor_addmonster(wave):
+ global uedit
+ uedit=allunitsbase[current]
+ pointer=uedit["waves"][wave-1]
+ if len(pointer) < 3:
+ pointer.append({
+ "name": "New Monster",
+ "sprite": 950000,
+ "attribute": 1,
+ "boss": False
+ })
+ else:
+ renpy.notify("Max monsters per wave reached!")
+ return
+
+ def ueditor_addwave():
+ global uedit
+ uedit=allunitsbase[current]
+ uedit["waves"].append([])
+ renpy.notify("Blank wave created\nThis is buggy, remember to add monsters")
+ return
+
+
+ def ueditor_delete(key1, key2=None, key3=None, key4=None):
+ global uedit
+ uedit=allunitsbase[current]
+ if key2 is None:
+ del uedit[key1]
+ #del allunitsbase[current][key1]
+ elif key3 is None:
+ del uedit[key1][key2]
+ #del allunitsbase[current][key1][key2]
+ elif key4 is None:
+ del uedit[key1][key2][key3]
+ #del allunitsbase[current][key1][key2][key3]
+ else:
+ del uedit[key1][key2][key3][key4]
+ #del allunitsbase[current][key1][key2][key3][key4]
+ return
+
+ def ueditor_input(key1, key2=None, tp="int", temp="", key3=None, key4=None):
+ #temp=renpy.input("Please insert new value for this variable.\nCurrent value: [variable]")
+ global uedit
+ uedit=allunitsbase[current]
+ variable=""
+
+ # Key looping
+ if key2 is None:
+ target=uedit[key1]
+ elif key3 is None:
+ target=uedit[key1][key2]
+ elif key4 is None:
+ target=uedit[key1][key2][key3]
+ else:
+ target=uedit[key1][key2][key3][key4]
+
+ # Convert input if needed
+ # tp int → convert to int
+ # tp key → Replace the key
+ # tp bool → Toogles the value
+ if tp == "int":
+ try:
+ variable=int(temp)
+ except:
+ renpy.notify("Invalid numeric input")
+ variable=0 # Sorry, but gets bad otherwise
+ elif tp == "key":
+ try:
+ uedit[key1][temp]=copy.copy(target)
+ renpy.notify("Key replaced")
+ del uedit[key1][key2] # Not sure "del target" would work
+ return
+ except:
+ renpy.notify("ERROR, doing nothing")
+ variable=target
+ elif tp == "bool":
+ try:
+ variable=(not target)
+ print "New boolean: %s" % str(variable)
+ except:
+ print "Illegal boolean"
+ renpy.notify("Illegal boolean")
+ variable=target
+ else:
+ try:
+ variable=str(temp)
+ except:
+ renpy.notify("Invalid string input")
+
+ # Save input
+ # Key looping
+ if key2 is None:
+ target=uedit[key1]=variable
+ elif key3 is None:
+ target=uedit[key1][key2]=variable
+ elif key4 is None:
+ target=uedit[key1][key2][key3]=variable
+ else:
+ target=uedit[key1][key2][key3][key4]=variable
+
+ return
+
+label units_editors:
+ $ uedit=allunitsbase[0]
+ $ current=0
+ $print("")
+ $print(".:: THE BUILT-IN QUEST EDITOR ::.")
+ $print("Use ESC to redraw screen, saving input")
+ $print("")
+ call screen units_editor
+ $print("Quest Editor closed")
+ menu:
+ "Save Changes":
+ $ ueditor_save()
+ "Discard Changes":
+ pass
+ jump restore
+