Skip to content

Commit

Permalink
Merge branch 'elementGen'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsunami014 committed Jan 6, 2024
2 parents 24b227b + f0e8528 commit 01540d0
Show file tree
Hide file tree
Showing 69 changed files with 1,721 additions and 652 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ keys/apiKeys.key
*.db
*.ldtk
*.json
*.elm
data/worlds/*/*
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"STT",
"characters",
"sound gen",
"other"
"other",
"nodes"
],
"wolf.disableHotModeWarning": true
}
Binary file added UIpack/Bonus/click1.ogg
Binary file not shown.
Binary file added UIpack/Bonus/click2.ogg
Binary file not shown.
Binary file added UIpack/Bonus/rollover1.ogg
Binary file not shown.
Binary file added UIpack/Bonus/rollover2.ogg
Binary file not shown.
Binary file added UIpack/Bonus/switch2.ogg
Binary file not shown.
Binary file added UIpack/Bonus/switch3.ogg
Binary file not shown.
Binary file added UIpack/Font/kenvector_future.ttf
Binary file not shown.
Binary file added UIpack/Font/kenvector_future_thin.ttf
Binary file not shown.
92 changes: 92 additions & 0 deletions UIpack/GUI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import pygame
pygame.init()
WIN = pygame.display.set_mode((500, 500))

import os
if os.getcwd().endswith('UIpack'):
app = ''
else: app = 'UIpack/'

from xml.dom.minidom import parse
def getAll(colour):
if colour == 'PNG':
return {i.name[:-4]: pygame.image.load(app+'PNGs/'+i.name).convert_alpha() for i in os.listdir(app+'PNGs')}
p = parse(app+'Spritesheet/%sSheet.xml'%colour)
sur = pygame.image.load(app+'Spritesheet/%sSheet.png'%colour).convert_alpha()
#a = {i.attributes._attrs['name'].value: {j: int(i.attributes._attrs[j].value) for j in i.attributes._attrs.keys() if j != 'name'} for i in p.getElementsByTagName('SubTexture')}
return {i.attributes._attrs['name'].value[len(colour)+1:-4]:
sur.subsurface(pygame.Rect(
int(i.attributes._attrs['x'].value),
int(i.attributes._attrs['y'].value),
int(i.attributes._attrs['width'].value),
int(i.attributes._attrs['height'].value)
)) for i in p.getElementsByTagName('SubTexture')}

def get_specific(name):
try:
colour = name[:name.index('_')]
except:
raise NameError(
f'The colour for the name {name} was not found!\n\
The colour of the element should be before the first \'_\' (e.g. `grey_button01` the colour would be grey)'
)
if colour == 'PNG':
return pygame.image.load(app+'PNGs/'+name[4:]).convert_alpha()
p = parse(app+'Spritesheet/%sSheet.xml'%colour)
sur = pygame.image.load(app+'Spritesheet/%sSheet.png'%colour).convert_alpha()
elms = p.getElementsByTagName('SubTexture')
i = None
for j in elms:
if j.attributes._attrs['name'] == name:
i = j
break
if i == None:
raise NameError(
f'The name "{name}" was not found in the coloursheet "{colour}"!'
)
return sur.subsurface(pygame.Rect(
int(i.attributes._attrs['x'].value),
int(i.attributes._attrs['y'].value),
int(i.attributes._attrs['width'].value),
int(i.attributes._attrs['height'].value)
))

import UIpack.consts as Cs
from json import load
def Element(elm, colour, state=None):
"""Get the code for an element!
Parameters
----------
elm : `Cs._____` (NOT `Cs.C______`)
The element to get the value of
colour : `Cs.C_____`
The colour of the element
Please note also that some elements are just one colour, so this value will be ignored. But not all, so still include it anyways
state : tuple, optional
This is only for buttons, by default None
For a button you need to specify the following in the tuple in this order:
- The size of the button (`Cs.S_____`)
- Whether the button is pressed ('D' for Down) or not pressed ('U' for Up)
PLEASE NOTE THAT OUTLINE BUTTONS HAVE NO DOWN STATE SO DO NOT ATTEMPT TO GET THEIR DOWN STATE
Returns
-------
str
The code for an element. To get the pic, use `get_specific(result)`
"""
if elm == Cs.HEMPTY:
return 'grey_box'
elif elm == Cs.OINPUT:
return 'grey_button05'
elif elm == Cs.RBLANK:
return 'grey_circle'
elif elm.startswith('A'): # Arrow
return 'grey_arrow'+elm[1:]
elif elm.startswith('D'): # Dropdown
'PNG_dropdown'+elm[1:]
else:
j = load(open(app+'Spritesheet/key.json'))
if elm.startswith('B'): # Button
return colour + '_' + 'button' + j[colour[1:]]['B'][elm[1]+state[0][1]+state[1]]
else:
return colour + '_' + j[colour[1:]][elm[0]][elm[1]]
Binary file added UIpack/PNGs/dropdownBottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added UIpack/PNGs/dropdownMid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added UIpack/PNGs/dropdownTop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added UIpack/Spritesheet/blueSheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions UIpack/Spritesheet/blueSheet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<TextureAtlas imagePath="sheet.png">
<SubTexture name="blue_boxCheckmark.png" x="380" y="36" width="38" height="36"/>
<SubTexture name="blue_boxCross.png" x="380" y="0" width="38" height="36"/>
<SubTexture name="blue_boxTick.png" x="386" y="210" width="36" height="36"/>
<SubTexture name="blue_button00.png" x="0" y="94" width="190" height="49"/>
<SubTexture name="blue_button01.png" x="190" y="49" width="190" height="45"/>
<SubTexture name="blue_button02.png" x="190" y="0" width="190" height="49"/>
<SubTexture name="blue_button03.png" x="0" y="49" width="190" height="45"/>
<SubTexture name="blue_button04.png" x="0" y="0" width="190" height="49"/>
<SubTexture name="blue_button05.png" x="0" y="192" width="190" height="45"/>
<SubTexture name="blue_button06.png" x="288" y="194" width="49" height="49"/>
<SubTexture name="blue_button07.png" x="239" y="194" width="49" height="49"/>
<SubTexture name="blue_button08.png" x="190" y="194" width="49" height="45"/>
<SubTexture name="blue_button09.png" x="339" y="94" width="49" height="49"/>
<SubTexture name="blue_button10.png" x="290" y="94" width="49" height="45"/>
<SubTexture name="blue_button11.png" x="337" y="184" width="49" height="49"/>
<SubTexture name="blue_button12.png" x="290" y="139" width="49" height="45"/>
<SubTexture name="blue_button13.png" x="0" y="143" width="190" height="49"/>
<SubTexture name="blue_checkmark.png" x="337" y="233" width="21" height="20"/>
<SubTexture name="blue_circle.png" x="386" y="174" width="36" height="36"/>
<SubTexture name="blue_cross.png" x="0" y="237" width="18" height="18"/>
<SubTexture name="blue_panel.png" x="190" y="94" width="100" height="100"/>
<SubTexture name="blue_sliderDown.png" x="416" y="72" width="28" height="42"/>
<SubTexture name="blue_sliderLeft.png" x="339" y="143" width="39" height="31"/>
<SubTexture name="blue_sliderRight.png" x="378" y="143" width="39" height="31"/>
<SubTexture name="blue_sliderUp.png" x="388" y="72" width="28" height="42"/>
<SubTexture name="blue_tick.png" x="18" y="239" width="17" height="17"/>
</TextureAtlas>
Binary file added UIpack/Spritesheet/greenSheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions UIpack/Spritesheet/greenSheet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<TextureAtlas imagePath="sheet.png">
<SubTexture name="green_boxCheckmark.png" x="380" y="0" width="38" height="36"/>
<SubTexture name="green_boxCross.png" x="380" y="36" width="38" height="36"/>
<SubTexture name="green_boxTick.png" x="386" y="210" width="36" height="36"/>
<SubTexture name="green_button00.png" x="0" y="0" width="190" height="49"/>
<SubTexture name="green_button01.png" x="0" y="49" width="190" height="45"/>
<SubTexture name="green_button02.png" x="0" y="94" width="190" height="49"/>
<SubTexture name="green_button03.png" x="0" y="192" width="190" height="45"/>
<SubTexture name="green_button04.png" x="190" y="0" width="190" height="49"/>
<SubTexture name="green_button05.png" x="190" y="49" width="190" height="45"/>
<SubTexture name="green_button06.png" x="337" y="184" width="49" height="49"/>
<SubTexture name="green_button07.png" x="339" y="94" width="49" height="49"/>
<SubTexture name="green_button08.png" x="290" y="139" width="49" height="45"/>
<SubTexture name="green_button09.png" x="190" y="194" width="49" height="49"/>
<SubTexture name="green_button10.png" x="290" y="94" width="49" height="45"/>
<SubTexture name="green_button11.png" x="288" y="194" width="49" height="49"/>
<SubTexture name="green_button12.png" x="239" y="194" width="49" height="45"/>
<SubTexture name="green_button13.png" x="0" y="143" width="190" height="49"/>
<SubTexture name="green_checkmark.png" x="337" y="233" width="21" height="20"/>
<SubTexture name="green_circle.png" x="386" y="174" width="36" height="36"/>
<SubTexture name="green_cross.png" x="0" y="237" width="18" height="18"/>
<SubTexture name="green_panel.png" x="190" y="94" width="100" height="100"/>
<SubTexture name="green_sliderDown.png" x="388" y="72" width="28" height="42"/>
<SubTexture name="green_sliderLeft.png" x="378" y="143" width="39" height="31"/>
<SubTexture name="green_sliderRight.png" x="339" y="143" width="39" height="31"/>
<SubTexture name="green_sliderUp.png" x="416" y="72" width="28" height="42"/>
<SubTexture name="green_tick.png" x="18" y="237" width="17" height="17"/>
</TextureAtlas>
Binary file added UIpack/Spritesheet/greySheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions UIpack/Spritesheet/greySheet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<TextureAtlas imagePath="sheet.png">
<SubTexture name="grey_arrowDownGrey.png" x="78" y="498" width="15" height="10"/>
<SubTexture name="grey_arrowDownWhite.png" x="123" y="496" width="15" height="10"/>
<SubTexture name="grey_arrowUpGrey.png" x="108" y="498" width="15" height="10"/>
<SubTexture name="grey_arrowUpWhite.png" x="93" y="498" width="15" height="10"/>
<SubTexture name="grey_box.png" x="147" y="433" width="38" height="36"/>
<SubTexture name="grey_boxCheckmark.png" x="147" y="469" width="38" height="36"/>
<SubTexture name="grey_boxCross.png" x="185" y="433" width="38" height="36"/>
<SubTexture name="grey_boxTick.png" x="190" y="198" width="36" height="36"/>
<SubTexture name="grey_button00.png" x="0" y="143" width="190" height="45"/>
<SubTexture name="grey_button01.png" x="0" y="188" width="190" height="49"/>
<SubTexture name="grey_button02.png" x="0" y="98" width="190" height="45"/>
<SubTexture name="grey_button03.png" x="0" y="331" width="190" height="49"/>
<SubTexture name="grey_button04.png" x="0" y="286" width="190" height="45"/>
<SubTexture name="grey_button05.png" x="0" y="0" width="195" height="49"/>
<SubTexture name="grey_button06.png" x="0" y="49" width="191" height="49"/>
<SubTexture name="grey_button07.png" x="195" y="0" width="49" height="49"/>
<SubTexture name="grey_button08.png" x="240" y="49" width="49" height="49"/>
<SubTexture name="grey_button09.png" x="98" y="433" width="49" height="45"/>
<SubTexture name="grey_button10.png" x="191" y="49" width="49" height="49"/>
<SubTexture name="grey_button11.png" x="0" y="433" width="49" height="45"/>
<SubTexture name="grey_button12.png" x="244" y="0" width="49" height="49"/>
<SubTexture name="grey_button13.png" x="49" y="433" width="49" height="45"/>
<SubTexture name="grey_button14.png" x="0" y="384" width="190" height="49"/>
<SubTexture name="grey_button15.png" x="0" y="237" width="190" height="49"/>
<SubTexture name="grey_checkmarkGrey.png" x="99" y="478" width="21" height="20"/>
<SubTexture name="grey_checkmarkWhite.png" x="78" y="478" width="21" height="20"/>
<SubTexture name="grey_circle.png" x="185" y="469" width="36" height="36"/>
<SubTexture name="grey_crossGrey.png" x="120" y="478" width="18" height="18"/>
<SubTexture name="grey_crossWhite.png" x="190" y="318" width="18" height="18"/>
<SubTexture name="grey_panel.png" x="190" y="98" width="100" height="100"/>
<SubTexture name="grey_sliderDown.png" x="190" y="234" width="28" height="42"/>
<SubTexture name="grey_sliderEnd.png" x="138" y="478" width="8" height="10"/>
<SubTexture name="grey_sliderHorizontal.png" x="0" y="380" width="190" height="4"/>
<SubTexture name="grey_sliderLeft.png" x="0" y="478" width="39" height="31"/>
<SubTexture name="grey_sliderRight.png" x="39" y="478" width="39" height="31"/>
<SubTexture name="grey_sliderUp.png" x="190" y="276" width="28" height="42"/>
<SubTexture name="grey_sliderVertical.png" x="208" y="318" width="4" height="100"/>
<SubTexture name="grey_tickGrey.png" x="190" y="336" width="17" height="17"/>
<SubTexture name="grey_tickWhite.png" x="190" y="353" width="17" height="17"/>
</TextureAtlas>
142 changes: 142 additions & 0 deletions UIpack/Spritesheet/key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"blue": {
"B": {
"RLU": "00",
"RLD": "01",
"FLU": "02",
"FLD": "03",
"GLU": "04",
"GLD": "05",
"OLU": "13",
"OSU": "06",
"RSU": "07",
"RSD": "08",
"FSU": "09",
"FSD": "10",
"GSU": "11",
"GSD": "12"
},
"H": {
"T": "boxCheckmark",
"C": "boxCross"
},
"R": {
"S": "boxTick"
},
"O": {
"P": "panel"
}
},
"green": {
"B": {
"RLU": "00",
"RLD": "01",
"FLU": "02",
"FLD": "03",
"GLU": "04",
"GLD": "05",
"OLU": "13",
"OSU": "06",
"RSU": "07",
"RSD": "08",
"FSU": "09",
"FSD": "10",
"GSU": "11",
"GSD": "12"
},
"H": {
"T": "boxCheckmark",
"C": "boxCross"
},
"R": {
"S": "boxTick"
},
"O": {
"P": "panel"
}
},
"grey": {
"B": {
"RLU": "00",
"RLD": "00",
"FLU": "01",
"FLD": "02",
"GLU": "03",
"GLD": "04",
"OLU": "06",
"OSU": "07",
"RSU": "08",
"RSD": "09",
"FSU": "10",
"FSD": "11",
"GSU": "12",
"GSD": "13"
},
"H": {
"T": "boxCheckmark",
"C": "boxCross"
},
"R": {
"S": "boxTick"
},
"O": {
"P": "panel"
}
},
"red": {
"B": {
"RLU": "00",
"RLD": "01",
"FLU": "02",
"FLD": "03",
"GLU": "04",
"GLD": "05",
"OLU": "13",
"OSU": "06",
"RSU": "07",
"RSD": "08",
"FSU": "09",
"FSD": "10",
"GSU": "11",
"GSD": "12"
},
"H": {
"T": "boxCheckmark",
"C": "boxCross"
},
"R": {
"S": "boxTick"
},
"O": {
"P": "panel"
}
},
"yellow": {
"B": {
"RLU": "00",
"RLD": "01",
"FLU": "02",
"FLD": "03",
"GLU": "04",
"GLD": "05",
"OLU": "13",
"OSU": "06",
"RSU": "07",
"RSD": "08",
"FSU": "09",
"FSD": "10",
"GSU": "11",
"GSD": "12"
},
"H": {
"T": "boxCheckmark",
"C": "boxCross"
},
"R": {
"S": "boxTick"
},
"O": {
"P": "panel"
}
}
}
Binary file added UIpack/Spritesheet/redSheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions UIpack/Spritesheet/redSheet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<TextureAtlas imagePath="sheet.png">
<SubTexture name="red_boxCheckmark.png" x="380" y="0" width="38" height="36"/>
<SubTexture name="red_boxCross.png" x="380" y="36" width="38" height="36"/>
<SubTexture name="red_boxTick.png" x="386" y="178" width="36" height="36"/>
<SubTexture name="red_button00.png" x="0" y="0" width="190" height="45"/>
<SubTexture name="red_button01.png" x="0" y="45" width="190" height="49"/>
<SubTexture name="red_button02.png" x="0" y="94" width="190" height="45"/>
<SubTexture name="red_button03.png" x="337" y="188" width="49" height="49"/>
<SubTexture name="red_button04.png" x="339" y="98" width="49" height="49"/>
<SubTexture name="red_button05.png" x="290" y="98" width="49" height="45"/>
<SubTexture name="red_button06.png" x="288" y="198" width="49" height="49"/>
<SubTexture name="red_button07.png" x="290" y="143" width="49" height="45"/>
<SubTexture name="red_button08.png" x="239" y="198" width="49" height="49"/>
<SubTexture name="red_button09.png" x="190" y="198" width="49" height="45"/>
<SubTexture name="red_button10.png" x="190" y="49" width="190" height="49"/>
<SubTexture name="red_button11.png" x="190" y="0" width="190" height="49"/>
<SubTexture name="red_button12.png" x="0" y="188" width="190" height="45"/>
<SubTexture name="red_button13.png" x="0" y="139" width="190" height="49"/>
<SubTexture name="red_checkmark.png" x="0" y="233" width="21" height="20"/>
<SubTexture name="red_circle.png" x="386" y="214" width="36" height="36"/>
<SubTexture name="red_cross.png" x="21" y="233" width="18" height="18"/>
<SubTexture name="red_panel.png" x="190" y="98" width="100" height="100"/>
<SubTexture name="red_sliderDown.png" x="388" y="72" width="28" height="42"/>
<SubTexture name="red_sliderLeft.png" x="339" y="147" width="39" height="31"/>
<SubTexture name="red_sliderRight.png" x="378" y="147" width="39" height="31"/>
<SubTexture name="red_sliderUp.png" x="416" y="72" width="28" height="42"/>
<SubTexture name="red_tick.png" x="39" y="233" width="17" height="17"/>
</TextureAtlas>
Binary file added UIpack/Spritesheet/yellowSheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 01540d0

Please sign in to comment.