Advertisement
Sterkiherz

court record-code

Feb 10th, 2024
1,492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.16 KB | None | 0 0
  1. #court record code:
  2. #------------------------------------------
  3. init python:
  4.  
  5.     class profile:
  6.         """ basically, whatever fields you want for your profiles will go here
  7.        base: all files/references to this character have this name"""
  8.         def __init__(self, name, fullname, occupation, info, base):
  9.             self.name = name
  10.             self.fullname = fullname
  11.             self.occupation = occupation
  12.             self.info = info
  13.             self.base = base
  14.         def change(self, info):
  15.             # this allows you to change the "info" field.
  16.             if info:
  17.                 self.info = info
  18.  
  19.     class evidence:
  20.         #this follows exactly the same format as profiles
  21.         def __init__(self, name, info, base):
  22.             self.name = name
  23.             self.info = info
  24.             self.base = base
  25.         def change(self, info):
  26.             if info:
  27.                 self.info = info
  28.  
  29.  
  30.     class currentChar:
  31.         #  the character you are presenting evidence to
  32.         def __init__(self, name, evidenceList):
  33.             self.name = name
  34.             self.evidenceList = evidenceList
  35.         def checkEvidence(self, currentEvidence):
  36.             if str(currentEvidence) in self.evidenceList:
  37.                 return currentEvidence
  38.             else:
  39.                 return "default"
  40.  
  41.     class courtRec:
  42.         i = 0
  43.         def __init__(self, evidence):
  44.             self.evidence = evidence
  45.             self.evidenceDict = {}
  46.             if evidence_type == "profiles":
  47.                 for e in evidence:
  48.                     self.evidenceDict[e.base] = [e.fullname, e.occupation, e.info]
  49.             else:
  50.                 for e in evidence:
  51.                     self.evidenceDict[e.base] = [e.name, e.info]
  52.                
  53.         def currentPic(self):
  54.             for e in self.evidence:
  55.                 self.i += 1
  56.                 if self.i <= (ev_page + 1) * ev_icons and self.i > ev_page * ev_icons:
  57.                     current_pic = "images/" + e.base + "_0.png"
  58.                     renpy.ui.imagebutton(idle=str(current_pic), hover=str(current_pic), action=[SetVariable("current", e.base), ShowMenu("cr_detail")])                    
  59.         def getPage(self):
  60.             next_ev_page = ev_page + 1
  61.             if next_ev_page > int(len(self.evidence)/ev_icons):
  62.                 next_ev_page = 0
  63.             prev_ev_page = ev_page - 1
  64.             if prev_ev_page < 0:
  65.                 prev_ev_page = 0
  66.             return [prev_ev_page, next_ev_page]
  67.         def baseList(self):
  68.             baselist = []
  69.             for e in self.evidence:
  70.                 baselist.append(e.base)
  71.             return baselist
  72.         def entryNumbers(self, currentEntry):
  73.             self.currentEntry = currentEntry
  74.             baselist = self.baseList()
  75.             numdic = {k: v for v, k in enumerate(baselist)}
  76.             currentEntryIndex = numdic[self.currentEntry]
  77.             prevEntryIndex = currentEntryIndex - 1
  78.             nextEntryIndex = currentEntryIndex + 1              
  79.             if prevEntryIndex < 0:
  80.                 prevEntryIndex = len(self.evidence) -1
  81.             nextEntryIndex = currentEntryIndex + 1
  82.             if nextEntryIndex > len(self.evidence) - 1:
  83.                 nextEntryIndex = 0
  84.             return [prevEntryIndex, nextEntryIndex]
  85.         def getDetails(self):
  86.             return self.evidenceDict[current]
  87.  
  88.  
  89. ##### COURT RECORD SCREEN
  90.  
  91. init -2:
  92.     $ ev_xpos = 0
  93.     $ ev_ypos = 120
  94.     $ ev_icon_size = 270
  95.     $ ev_row1 = 120
  96.     $ ev_row2 = 520
  97.     $ ev_row3 = 120
  98.  
  99.     #Icon grid
  100.     $ ev_icon_column = 4
  101.     $ ev_icon_row = 2
  102.     $ ev_icons = ev_icon_column * ev_icon_row
  103.     $ ev_page = 0
  104.     $ next_ev_page = 0
  105.     $ prev_ev_page = 0
  106.  
  107.     $ info = ""
  108.     $ current = ""
  109.     $ evidence_type = "profiles"
  110.  
  111. screen court_record:
  112.     tag menu
  113.     modal True
  114.  
  115.     if evidence_type == "evidence":
  116.         $ records = courtRec(my_evidence)
  117.     elif evidence_type == "profiles":
  118.         $ records = courtRec(my_profiles)
  119.  
  120.     frame:
  121.         $ pages = records.getPage()
  122.         xsize 1280
  123.         ysize 720
  124.         background Frame("evidence_window.png")
  125.         if ev_page > 0:
  126.             imagebutton:
  127.                 idle "0_left_button.png"
  128.                 hover "1_left_button.png"
  129.                 action [SetVariable('ev_page', pages[0])]
  130.  
  131.         hbox:
  132.             xpos 105
  133.             xsize 1080
  134.  
  135.             vpgrid:
  136.                 cols ev_icon_column
  137.                 rows ev_icon_row
  138.                 draggable False
  139.                 mousewheel False
  140.                
  141.                
  142.                 $ records.currentPic()
  143.  
  144.         hbox:
  145.             xpos 1180
  146.             xsize 100
  147.             if pages[1] > 0:
  148.                 imagebutton:
  149.                     yalign 0.5
  150.                     idle "0_right_button.png"
  151.                     hover "1_right_button.png"
  152.                     action [SetVariable('ev_page', pages[1])]
  153.  
  154.     vbox:
  155.         ypos 500
  156.         xpos 20
  157.         xsize 880
  158.         hbox:
  159.             xpos 640
  160.             xanchor 0.5
  161.             if evidence_type == "evidence":
  162.                 imagebutton auto "profile_button_%s.png" action [SetVariable("current", ""), SetVariable("ev_page", 0), SetVariable("evidence_type", "profiles")]
  163.  
  164.             elif evidence_type == "profiles":
  165.                 imagebutton auto "evidence_button_%s.png" action [SetVariable("current", ""), SetVariable("ev_page", 0), SetVariable("next_ev_page", 0), SetVariable("evidence_type", "evidence")]
  166.             imagebutton auto "close_%s.png" action [SetVariable("ev_page", 0), Hide('court_record'), Jump(current_scene)]
  167.  
  168. screen cr_detail:
  169.     tag menu
  170.     modal True
  171.  
  172.     if npc != False:
  173.         $ ev_label = npc.name + "_" + npc.checkEvidence(str(current))
  174.  
  175.     if evidence_type == "evidence":
  176.         $ records = courtRec(my_evidence)
  177.         $
  178.     elif evidence_type == "profiles":
  179.         $ records = courtRec(my_profiles)
  180.     $ entryNumbers = records.entryNumbers(current)
  181.     $ baselist = records.baseList()
  182.     $ prev_detail_page = entryNumbers[0]
  183.     $ next_detail_page = entryNumbers[1]
  184.  
  185.  
  186.  
  187.     frame:
  188.         xsize 1280
  189.         ysize 720
  190.         background Frame("evidence_detail_window.png")
  191.  
  192.  
  193.  
  194.         imagebutton:
  195.             idle "0_left_button.png"
  196.             hover "1_left_button.png"
  197.             action [SetVariable('current', baselist[prev_detail_page])]
  198.  
  199.         hbox:
  200.             xpos 105
  201.             xsize 400
  202.  
  203.             $ current_pic = "/images/" + current + "_1.png"
  204.             add current_pic
  205.                
  206.         hbox:
  207.             xpos 680
  208.             ypos 60
  209.             vbox:
  210.                 ysize 200
  211.                 xsize 500
  212.                 if current == "":
  213.                     text ""
  214.                 else:
  215.                     $ details = records.getDetails()
  216.                 if evidence_type == "profiles":
  217.                     text "{size=+5}{b}Name:{/b} " + details[0] + "{/size}"
  218.                 if evidence_type == "evidence":
  219.                     text details[0]
  220.  
  221.                 vbox:
  222.                     ysize 120
  223.                 if evidence_type == "profiles":
  224.                     text "{b}Occupation:{/b} " + details[1]
  225.                     $ evinfo = details[2]
  226.                 if evidence_type == "evidence":
  227.                     $ evinfo = details[1]
  228.                 for e in evinfo:
  229.                     text e
  230.  
  231.         hbox:
  232.             xpos 1180
  233.             xsize 100
  234.             imagebutton:
  235.                 yalign 0.5
  236.                 idle "0_right_button.png"
  237.                 hover "1_right_button.png"
  238.                 action [SetVariable('current', baselist[next_detail_page])]
  239.  
  240.         vbox:
  241.             xpos 20
  242.             ypos 500
  243.             hbox:
  244.                 xpos 640
  245.                 xanchor 0.5
  246.                 imagebutton auto "profile_button_%s.png" action [Hide("cr_detail"), SetVariable("current", ""), SetVariable("ev_page", 0), SetVariable("evidence_type", "profiles"), Show("court_record ")]
  247.                 imagebutton auto "evidence_button_%s.png" action [Hide("cr_detail"), SetVariable("current", ""), SetVariable("ev_page", 0), SetVariable("next_ev_page", 0), SetVariable("evidence_type", "evidence"), Show("court_record ")]                
  248.                 if npc != False:
  249.                     $ ev_label = npc.name + "_" + npc.checkEvidence(current)
  250.                     imagebutton auto "present_button_%s.png" action [Hide("cr_detail"), Jump(ev_label)]
  251.                 imagebutton auto "close_%s.png" action [Hide('cr_detail'), Jump(current_scene)]
  252.  
  253.  
  254.  
  255. ############ Evidence Menu Buttons
  256. #the menu for the corner of the screen
  257. screen evidence_menu:
  258.     imagebutton auto "profile_button_sm_%s.png" action [SetVariable("current", ""), SetVariable("evidence_type", "profiles"), ShowMenu("court_record")]  xalign .90 yalign .02  focus_mask True
  259.     imagebutton auto "evidence_button_sm_%s.png" action [SetVariable("current", ""), SetVariable("evidence_type", "evidence"), ShowMenu("court_record")]  xalign .98 yalign .02 focus_mask True
  260.     imagebutton auto "assistant_%s.png" action [Jump(assistant)] xalign .977 yalign .16  focus_mask True
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement