def __init__(self, questID): ScriptWidget.__init__(self) ActionListener.__init__(self) self.bg = Sprite("DATA/FormPQuest2/2BG.gi") self.addChild(self.bg) self.paramWindow = NinePatch("ORC/quest_param_win.9.json") self.paramWindow.position = (643, 457) self.paramWindow.geometry = (320, 280) self.addChild(self.paramWindow) self.exitButton = Button("DATA/FormPQuest2/2CloseN.gi", "DATA/FormPQuest2/2CloseA.gi", "DATA/FormPQuest2/2CloseD.gi") self.exitButton.position = (953, 725) self.addWidget(self.exitButton) self.exitButton.addListener(self) self.image = None self.questID = questID self.questFile = resources.datRoot()['PlanetQuest']['PlanetQuest'][questID].value.replace('\\', '/') player.loadQuest(self.questFile) self.loadImages() self.style = resources.objectManager().getResourceObject('/world/skin/quest/grey') self.interact = InteractionWidget(Rect(15, 45, 15 + 539, 45 + 363), Rect(15, 482, 15 + 539, 482 + 215), self.style) self.interact.position = (35, 5) self.interact.layer = -2; self.addWidget(self.interact) self.interact.addListener(self) self.paramLabel = ColorLabel("") self.paramLabel.wordWrap = True self.paramLabel.position = (665, 480) self.paramLabel.setFixedSize(280, 280) self.paramLabel.textColor = self.style.color self.paramLabel.selectionColor = self.style.activeColor self.addChild(self.paramLabel) self.skin1Button = Button("DATA/FormPQuest2/2Skin1N.gi", "DATA/FormPQuest2/2Skin1A.gi", "DATA/FormPQuest2/2Skin1D.gi") self.skin1Button.position = (529, 742) self.addWidget(self.skin1Button) self.skin1Button.addListener(self) self.skin2Button = Button("DATA/FormPQuest2/2Skin2N.gi", "DATA/FormPQuest2/2Skin2A.gi", "DATA/FormPQuest2/2Skin2D.gi") self.skin2Button.position = (547, 742) self.addWidget(self.skin2Button) self.skin2Button.addListener(self) self.skin3Button = Button("DATA/FormPQuest2/2Skin3N.gi", "DATA/FormPQuest2/2Skin3A.gi", "DATA/FormPQuest2/2Skin3D.gi") self.skin3Button.position = (565, 742) self.addWidget(self.skin3Button) self.skin3Button.addListener(self) self.skin4Button = Button("DATA/FormPQuest2/2Skin4N.gi", "DATA/FormPQuest2/2Skin4A.gi", "DATA/FormPQuest2/2Skin4D.gi") self.skin4Button.position = (583, 742) self.addWidget(self.skin4Button) self.skin4Button.addListener(self) self.updateWidget()
def select(self, button): if button == None: return if self.selected == button: return if self.selected != None: self.selected.removeListener(self) self.node.removeWidget(self.selected) i = self.buttons[self.selected] del self.buttons[self.selected] self.selected = Button("DATA/FormLoadQuest/2SlotNormal.gi", "DATA/FormLoadQuest/2SlotOnMouse.gi", "DATA/FormLoadQuest/2SlotOnPress.gi") self.selected.position = (0, 5 + i * (self.selected.height + 5)) self.node.addWidget(self.selected) self.selected.addListener(self) self.buttons[self.selected] = i button.removeListener(self) self.node.removeWidget(button) i = self.buttons[button] del self.buttons[button] self.selected = Button("DATA/FormLoadQuest/2SlotActive.gi") self.selected.position = (0, 5 + i * (self.selected.height + 5)) self.node.addWidget(self.selected) self.buttons[self.selected] = i self.selected.addListener(self) #if self.image != None: #self.removeChild(self.image) #self.image = Sprite(self.quests[i].image) #self.image.layer = -2 #self.image.position = (640, 15) #self.image.geometry = (200, 228) #self.addChild(self.image) self.selectedQuest = self.quests[i].id text = resources.datRoot()['PlanetQuest']['StartText'][ self.quests[i].id].value text = text.replace("<Player>", '\\cS' + self.rangerName + '\\cR') text = text.replace("<CurPlanet>", '\\cS' + self.fromPlanet + '\\cR') text = text.replace("<CurStar>", '\\cS' + self.fromStar + '\\cR') text = text.replace("<ToPlanet>", '\\cS' + self.toPlanet + '\\cR') text = text.replace("<ToStar>", '\\cS' + self.toStar + '\\cR') text = text.replace("<FromPlanet>", '\\cS' + self.fromPlanet + '\\cR') text = text.replace("<FromStar>", '\\cS' + self.fromStar + '\\cR') self.desc.text = text self.descScroll.markToUpdate()
def select(self, button): if button == None: return if self.selected == button: return if self.selected != None: self.selected.removeListener(self) self.node.removeWidget(self.selected) i = self.buttons[self.selected] del self.buttons[self.selected] self.selected = Button("DATA/FormLoadQuest/2SlotNormal.gi", "DATA/FormLoadQuest/2SlotOnMouse.gi", "DATA/FormLoadQuest/2SlotOnPress.gi") self.selected.position = (0, 5 + i * (self.selected.height + 5)) self.node.addWidget(self.selected) self.selected.addListener(self) self.buttons[self.selected] = i button.removeListener(self) self.node.removeWidget(button) i = self.buttons[button] del self.buttons[button] self.selected = Button("DATA/FormLoadQuest/2SlotActive.gi") self.selected.position = (0, 5 + i * (self.selected.height + 5)) self.node.addWidget(self.selected) self.buttons[self.selected] = i self.selected.addListener(self) #if self.image != None: #self.removeChild(self.image) #self.image = Sprite(self.quests[i].image) #self.image.layer = -2 #self.image.position = (640, 15) #self.image.geometry = (200, 228) #self.addChild(self.image) self.selectedQuest = self.quests[i].id text = resources.datRoot()['PlanetQuest']['StartText'][self.quests[i].id].value text = text.replace("<Player>", '\\cS' + self.rangerName + '\\cR') text = text.replace("<CurPlanet>", '\\cS' + self.fromPlanet + '\\cR') text = text.replace("<CurStar>", '\\cS' + self.fromStar + '\\cR') text = text.replace("<ToPlanet>", '\\cS' + self.toPlanet + '\\cR') text = text.replace("<ToStar>", '\\cS' + self.toStar + '\\cR') text = text.replace("<FromPlanet>", '\\cS' + self.fromPlanet + '\\cR') text = text.replace("<FromStar>", '\\cS' + self.fromStar + '\\cR') self.desc.text = text self.descScroll.markToUpdate()
def __init__(self): ScriptWidget.__init__(self) ActionListener.__init__(self) self.scrollStyle = resources.objectManager().getResourceObject( '/world/skin/quest/dark').scrollStyle if not self.scrollStyle: self.scrollStyle = engine.defaultSkin.scrollStyle font = resources.objectManager().getResourceObject('/fonts/default') self.smallFont = resources.loadFont(font.path, 12, font.antialiasing) self.font = resources.loadFont(font) self.buttonFont = resources.loadFont( resources.objectManager().getResourceObject('/fonts/ranger-bold')) self.buttonSounds = (engine.defaultSkin.buttonStyle.clickSound,\ engine.defaultSkin.buttonStyle.enterSound,\ engine.defaultSkin.buttonStyle.leaveSound) self.bg = Sprite("DATA/FormLoadQuest/2BG.gi") self.bg.layer = -1 self.addChild(self.bg) self.width = int(self.bg.width) self.height = int(self.bg.height) self.bg2 = Sprite("DATA/FormLoadQuest/2ImageBG.gi") self.bg2.layer = -3 self.bg2.position = (640, 15) self.addChild(self.bg2) self.image = None self.descNode = WidgetNode() self.descScroll = ScrollArea(self.scrollStyle, self.descNode) self.descScroll.position = (631, 280) self.descScroll.geometry = (280, 243) self.addWidget(self.descScroll) self.desc = ColorLabel() self.desc.font = self.font self.desc.position = (0, 5) self.desc.wordWrap = True self.desc.setFixedWidth(280) self.desc.textColor = Color(0.0, 0.0, 0.0) self.desc.selectionColor = Color(0.0, 0.0, 1.0) self.descWidget = LabelWidget(self.desc) self.descNode.addWidget(self.descWidget) self.node = WidgetNode() self.scroll = ScrollArea(self.scrollStyle, self.node) self.scroll.position = (40, 145) self.scroll.geometry = (528, 460) self.addWidget(self.scroll) self.startButton = Button('DATA/FormSave2/2SaveN.gi', '', 'DATA/FormSave2/2SaveD.gi') self.startButton.sounds = (self.buttonSounds[0], '', '') self.startButton.text = _('Start', 'FormLoadQuest.Start', 'OpenSR-World') self.startButton.font = self.buttonFont self.startButton.color = Color.fromString('#002842') self.startButton.position = (638, 574) self.startButton.layer = 1 self.startButton.addListener(self) self.addWidget(self.startButton) self.cancelButton = Button('DATA/FormSave2/2CancelN.gi', '', 'DATA/FormSave2/2CancelD.gi') self.cancelButton.sounds = (self.buttonSounds[0], '', '') self.cancelButton.text = _('Cancel', 'FormLoadQuest.Cancel', 'OpenSR-World') self.cancelButton.font = self.buttonFont self.cancelButton.color = Color.fromString('#002842') self.cancelButton.position = (638, 626) self.cancelButton.layer = 1 self.cancelButton.addListener(self) self.addWidget(self.cancelButton) self.closeButton = Button('DATA/FormSave2/2CloseN.gi', 'DATA/FormSave2/2CloseA.gi', 'DATA/FormSave2/2CloseD.gi') self.closeButton.sounds = self.buttonSounds self.closeButton.position = (891, 601) self.closeButton.layer = 1 self.closeButton.addListener(self) self.addWidget(self.closeButton) self.buttons = {} self.loadQuests() self.selected = None first = None i = 0 for q in self.quests: b = Button("DATA/FormLoadQuest/2SlotNormal.gi", "DATA/FormLoadQuest/2SlotOnMouse.gi", "DATA/FormLoadQuest/2SlotOnPress.gi") b.position = (0, 5 + i * (b.height + 5)) self.node.addWidget(b) self.buttons[b] = i b.addListener(self) if i == 0: first = b nl = Label(q.name) nl.font = self.font nl.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_CENTER) nl.position = (15, int(5 + i * (b.height + 5) + b.height / 2)) nl.layer = 1 nl.color = Color.fromString("#A5B68C") self.node.addChild(nl) if q.length < 1: diff = "DATA/FormLoadQuest/2D1.gi" elif q.length < 2: diff = "DATA/FormLoadQuest/2D2.gi" elif q.length < 3: diff = "DATA/FormLoadQuest/2D3.gi" elif q.length < 4: diff = "DATA/FormLoadQuest/2D4.gi" else: diff = "DATA/FormLoadQuest/2D5.gi" diffIcon = Sprite(diff) diffIcon.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_CENTER) diffIcon.position = (int(b.width / 2.2), int(5 + i * (b.height + 5) + b.height / 2)) diffIcon.layer = 1 self.node.addChild(diffIcon) gl = Label(q.genre) gl.font = self.smallFont gl.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_CENTER) gl.position = (int(b.width / 2.2) + 5 + diffIcon.width, int(5 + i * (b.height + 5) + b.height / 2)) gl.layer = 1 gl.color = Color.fromString("#A5B68C") gl.wordWrap = True gl.setFixedWidth(b.width - int(b.width / 2.2) - 5 - diffIcon.width) self.node.addChild(gl) i += 1 self.select(first)
class QuestSelectionWidget(ScriptWidget, ActionListener): def __init__(self): ScriptWidget.__init__(self) ActionListener.__init__(self) self.scrollStyle = resources.objectManager().getResourceObject( '/world/skin/quest/dark').scrollStyle if not self.scrollStyle: self.scrollStyle = engine.defaultSkin.scrollStyle font = resources.objectManager().getResourceObject('/fonts/default') self.smallFont = resources.loadFont(font.path, 12, font.antialiasing) self.font = resources.loadFont(font) self.buttonFont = resources.loadFont( resources.objectManager().getResourceObject('/fonts/ranger-bold')) self.buttonSounds = (engine.defaultSkin.buttonStyle.clickSound,\ engine.defaultSkin.buttonStyle.enterSound,\ engine.defaultSkin.buttonStyle.leaveSound) self.bg = Sprite("DATA/FormLoadQuest/2BG.gi") self.bg.layer = -1 self.addChild(self.bg) self.width = int(self.bg.width) self.height = int(self.bg.height) self.bg2 = Sprite("DATA/FormLoadQuest/2ImageBG.gi") self.bg2.layer = -3 self.bg2.position = (640, 15) self.addChild(self.bg2) self.image = None self.descNode = WidgetNode() self.descScroll = ScrollArea(self.scrollStyle, self.descNode) self.descScroll.position = (631, 280) self.descScroll.geometry = (280, 243) self.addWidget(self.descScroll) self.desc = ColorLabel() self.desc.font = self.font self.desc.position = (0, 5) self.desc.wordWrap = True self.desc.setFixedWidth(280) self.desc.textColor = Color(0.0, 0.0, 0.0) self.desc.selectionColor = Color(0.0, 0.0, 1.0) self.descWidget = LabelWidget(self.desc) self.descNode.addWidget(self.descWidget) self.node = WidgetNode() self.scroll = ScrollArea(self.scrollStyle, self.node) self.scroll.position = (40, 145) self.scroll.geometry = (528, 460) self.addWidget(self.scroll) self.startButton = Button('DATA/FormSave2/2SaveN.gi', '', 'DATA/FormSave2/2SaveD.gi') self.startButton.sounds = (self.buttonSounds[0], '', '') self.startButton.text = _('Start', 'FormLoadQuest.Start', 'OpenSR-World') self.startButton.font = self.buttonFont self.startButton.color = Color.fromString('#002842') self.startButton.position = (638, 574) self.startButton.layer = 1 self.startButton.addListener(self) self.addWidget(self.startButton) self.cancelButton = Button('DATA/FormSave2/2CancelN.gi', '', 'DATA/FormSave2/2CancelD.gi') self.cancelButton.sounds = (self.buttonSounds[0], '', '') self.cancelButton.text = _('Cancel', 'FormLoadQuest.Cancel', 'OpenSR-World') self.cancelButton.font = self.buttonFont self.cancelButton.color = Color.fromString('#002842') self.cancelButton.position = (638, 626) self.cancelButton.layer = 1 self.cancelButton.addListener(self) self.addWidget(self.cancelButton) self.closeButton = Button('DATA/FormSave2/2CloseN.gi', 'DATA/FormSave2/2CloseA.gi', 'DATA/FormSave2/2CloseD.gi') self.closeButton.sounds = self.buttonSounds self.closeButton.position = (891, 601) self.closeButton.layer = 1 self.closeButton.addListener(self) self.addWidget(self.closeButton) self.buttons = {} self.loadQuests() self.selected = None first = None i = 0 for q in self.quests: b = Button("DATA/FormLoadQuest/2SlotNormal.gi", "DATA/FormLoadQuest/2SlotOnMouse.gi", "DATA/FormLoadQuest/2SlotOnPress.gi") b.position = (0, 5 + i * (b.height + 5)) self.node.addWidget(b) self.buttons[b] = i b.addListener(self) if i == 0: first = b nl = Label(q.name) nl.font = self.font nl.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_CENTER) nl.position = (15, int(5 + i * (b.height + 5) + b.height / 2)) nl.layer = 1 nl.color = Color.fromString("#A5B68C") self.node.addChild(nl) if q.length < 1: diff = "DATA/FormLoadQuest/2D1.gi" elif q.length < 2: diff = "DATA/FormLoadQuest/2D2.gi" elif q.length < 3: diff = "DATA/FormLoadQuest/2D3.gi" elif q.length < 4: diff = "DATA/FormLoadQuest/2D4.gi" else: diff = "DATA/FormLoadQuest/2D5.gi" diffIcon = Sprite(diff) diffIcon.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_CENTER) diffIcon.position = (int(b.width / 2.2), int(5 + i * (b.height + 5) + b.height / 2)) diffIcon.layer = 1 self.node.addChild(diffIcon) gl = Label(q.genre) gl.font = self.smallFont gl.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_CENTER) gl.position = (int(b.width / 2.2) + 5 + diffIcon.width, int(5 + i * (b.height + 5) + b.height / 2)) gl.layer = 1 gl.color = Color.fromString("#A5B68C") gl.wordWrap = True gl.setFixedWidth(b.width - int(b.width / 2.2) - 5 - diffIcon.width) self.node.addChild(gl) i += 1 self.select(first) def select(self, button): if button == None: return if self.selected == button: return if self.selected != None: self.selected.removeListener(self) self.node.removeWidget(self.selected) i = self.buttons[self.selected] del self.buttons[self.selected] self.selected = Button("DATA/FormLoadQuest/2SlotNormal.gi", "DATA/FormLoadQuest/2SlotOnMouse.gi", "DATA/FormLoadQuest/2SlotOnPress.gi") self.selected.position = (0, 5 + i * (self.selected.height + 5)) self.node.addWidget(self.selected) self.selected.addListener(self) self.buttons[self.selected] = i button.removeListener(self) self.node.removeWidget(button) i = self.buttons[button] del self.buttons[button] self.selected = Button("DATA/FormLoadQuest/2SlotActive.gi") self.selected.position = (0, 5 + i * (self.selected.height + 5)) self.node.addWidget(self.selected) self.buttons[self.selected] = i self.selected.addListener(self) #if self.image != None: #self.removeChild(self.image) #self.image = Sprite(self.quests[i].image) #self.image.layer = -2 #self.image.position = (640, 15) #self.image.geometry = (200, 228) #self.addChild(self.image) self.selectedQuest = self.quests[i].id text = resources.datRoot()['PlanetQuest']['StartText'][ self.quests[i].id].value text = text.replace("<Player>", '\\cS' + self.rangerName + '\\cR') text = text.replace("<CurPlanet>", '\\cS' + self.fromPlanet + '\\cR') text = text.replace("<CurStar>", '\\cS' + self.fromStar + '\\cR') text = text.replace("<ToPlanet>", '\\cS' + self.toPlanet + '\\cR') text = text.replace("<ToStar>", '\\cS' + self.toStar + '\\cR') text = text.replace("<FromPlanet>", '\\cS' + self.fromPlanet + '\\cR') text = text.replace("<FromStar>", '\\cS' + self.fromStar + '\\cR') self.desc.text = text self.descScroll.markToUpdate() def loadQuests(self): dat = resources.datRoot() self.rangerName = dat['FormLoadQuest']['PRanger'].value self.toPlanet = dat['FormLoadQuest']['PToPlanet'].value self.toStar = dat['FormLoadQuest']['PToStar'].value self.fromPlanet = dat['FormLoadQuest']['PFromPlanet'].value self.fromStar = dat['FormLoadQuest']['PFromStar'].value self.quests = [] for q in dat['PlanetQuest']['List']: info = QuestInfo() info.id = q.name info.name = q['Name'].value info.genre = q['Genre'].value info.group = int(q['Group'].value) info.access = int(q['Access'].value) info.length = int(q['Length'].value) info.image = getCacheDATPath(q['Image'].value) info.difficulty = int(q['Dif'].value) self.quests.append(info) def dispose(self): for k in self.buttons.keys(): k.removeListener(self) self.cancelButton.removeListener(self) self.startButton.removeListener(self) self.closeButton.removeListener(self) def processLogic(self, dt): ScriptWidget.processLogic(self, dt) def actionPerformed(self, action): if action.type != Action.Type.BUTTON_CLICKED: return if action.source in self.buttons: self.select(action.source) elif action.source == self.startButton: self.action(Action(self, Action.Type.DIALOG_ACCEPT)) elif action.source == self.cancelButton: self.action(Action(self, Action.Type.DIALOG_CANCEL)) elif action.source == self.closeButton: self.action(Action(self, Action.Type.DIALOG_CANCEL))
def __init__(self): ScriptWidget.__init__(self) ActionListener.__init__(self) self.scrollStyle = resources.objectManager().getResourceObject('/world/skin/quest/dark').scrollStyle if not self.scrollStyle: self.scrollStyle = engine.defaultSkin.scrollStyle font = resources.objectManager().getResourceObject('/fonts/default') self.smallFont = resources.loadFont(font.path, 12, font.antialiasing) self.font = resources.loadFont(font) self.buttonFont = resources.loadFont(resources.objectManager().getResourceObject('/fonts/ranger-bold')) self.buttonSounds = (engine.defaultSkin.buttonStyle.clickSound,\ engine.defaultSkin.buttonStyle.enterSound,\ engine.defaultSkin.buttonStyle.leaveSound) self.bg = Sprite("DATA/FormLoadQuest/2BG.gi") self.bg.layer = -1 self.addChild(self.bg) self.width = int(self.bg.width) self.height = int(self.bg.height) self.bg2 = Sprite("DATA/FormLoadQuest/2ImageBG.gi") self.bg2.layer = -3 self.bg2.position = (640, 15) self.addChild(self.bg2) self.image = None self.descNode = WidgetNode() self.descScroll = ScrollArea(self.scrollStyle, self.descNode) self.descScroll.position = (631, 280) self.descScroll.geometry = (280, 243) self.addWidget(self.descScroll) self.desc = ColorLabel() self.desc.font = self.font self.desc.position = (0, 5) self.desc.wordWrap = True self.desc.setFixedWidth(280) self.desc.textColor = Color(0.0, 0.0, 0.0) self.desc.selectionColor = Color(0.0, 0.0, 1.0) self.descWidget = LabelWidget(self.desc) self.descNode.addWidget(self.descWidget) self.node = WidgetNode() self.scroll = ScrollArea(self.scrollStyle, self.node) self.scroll.position = (40, 145) self.scroll.geometry = (528, 460) self.addWidget(self.scroll) self.startButton = Button('DATA/FormSave2/2SaveN.gi', '', 'DATA/FormSave2/2SaveD.gi') self.startButton.sounds = (self.buttonSounds[0], '', '') self.startButton.text = _('Start', 'FormLoadQuest.Start', 'OpenSR-World') self.startButton.font = self.buttonFont self.startButton.color = Color.fromString('#002842') self.startButton.position = (638, 574) self.startButton.layer = 1 self.startButton.addListener(self) self.addWidget(self.startButton) self.cancelButton = Button('DATA/FormSave2/2CancelN.gi', '', 'DATA/FormSave2/2CancelD.gi') self.cancelButton.sounds = (self.buttonSounds[0], '', '') self.cancelButton.text = _('Cancel', 'FormLoadQuest.Cancel', 'OpenSR-World') self.cancelButton.font = self.buttonFont self.cancelButton.color = Color.fromString('#002842') self.cancelButton.position = (638, 626) self.cancelButton.layer = 1 self.cancelButton.addListener(self) self.addWidget(self.cancelButton) self.closeButton = Button('DATA/FormSave2/2CloseN.gi', 'DATA/FormSave2/2CloseA.gi', 'DATA/FormSave2/2CloseD.gi') self.closeButton.sounds = self.buttonSounds self.closeButton.position = (891, 601) self.closeButton.layer = 1 self.closeButton.addListener(self) self.addWidget(self.closeButton) self.buttons = {} self.loadQuests() self.selected = None first = None i = 0 for q in self.quests: b = Button("DATA/FormLoadQuest/2SlotNormal.gi", "DATA/FormLoadQuest/2SlotOnMouse.gi", "DATA/FormLoadQuest/2SlotOnPress.gi") b.position = (0, 5 + i * (b.height + 5)) self.node.addWidget(b) self.buttons[b] = i b.addListener(self) if i == 0: first = b nl = Label(q.name) nl.font = self.font nl.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_CENTER) nl.position = (15, int(5 + i * (b.height + 5) + b.height / 2)) nl.layer = 1 nl.color = Color.fromString("#A5B68C") self.node.addChild(nl) if q.length < 1: diff = "DATA/FormLoadQuest/2D1.gi" elif q.length < 2: diff = "DATA/FormLoadQuest/2D2.gi" elif q.length < 3: diff = "DATA/FormLoadQuest/2D3.gi" elif q.length < 4: diff = "DATA/FormLoadQuest/2D4.gi" else: diff = "DATA/FormLoadQuest/2D5.gi" diffIcon = Sprite(diff) diffIcon.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_CENTER) diffIcon.position = (int(b.width / 2.2), int(5 + i * (b.height + 5) + b.height / 2)) diffIcon.layer = 1 self.node.addChild(diffIcon) gl = Label(q.genre) gl.font = self.smallFont gl.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_CENTER) gl.position = (int(b.width / 2.2) + 5 + diffIcon.width, int(5 + i * (b.height + 5) + b.height / 2)) gl.layer = 1 gl.color = Color.fromString("#A5B68C") gl.wordWrap = True gl.setFixedWidth(b.width - int(b.width / 2.2) - 5 - diffIcon.width) self.node.addChild(gl) i += 1 self.select(first)
class QuestSelectionWidget(ScriptWidget, ActionListener): def __init__(self): ScriptWidget.__init__(self) ActionListener.__init__(self) self.scrollStyle = resources.objectManager().getResourceObject('/world/skin/quest/dark').scrollStyle if not self.scrollStyle: self.scrollStyle = engine.defaultSkin.scrollStyle font = resources.objectManager().getResourceObject('/fonts/default') self.smallFont = resources.loadFont(font.path, 12, font.antialiasing) self.font = resources.loadFont(font) self.buttonFont = resources.loadFont(resources.objectManager().getResourceObject('/fonts/ranger-bold')) self.buttonSounds = (engine.defaultSkin.buttonStyle.clickSound,\ engine.defaultSkin.buttonStyle.enterSound,\ engine.defaultSkin.buttonStyle.leaveSound) self.bg = Sprite("DATA/FormLoadQuest/2BG.gi") self.bg.layer = -1 self.addChild(self.bg) self.width = int(self.bg.width) self.height = int(self.bg.height) self.bg2 = Sprite("DATA/FormLoadQuest/2ImageBG.gi") self.bg2.layer = -3 self.bg2.position = (640, 15) self.addChild(self.bg2) self.image = None self.descNode = WidgetNode() self.descScroll = ScrollArea(self.scrollStyle, self.descNode) self.descScroll.position = (631, 280) self.descScroll.geometry = (280, 243) self.addWidget(self.descScroll) self.desc = ColorLabel() self.desc.font = self.font self.desc.position = (0, 5) self.desc.wordWrap = True self.desc.setFixedWidth(280) self.desc.textColor = Color(0.0, 0.0, 0.0) self.desc.selectionColor = Color(0.0, 0.0, 1.0) self.descWidget = LabelWidget(self.desc) self.descNode.addWidget(self.descWidget) self.node = WidgetNode() self.scroll = ScrollArea(self.scrollStyle, self.node) self.scroll.position = (40, 145) self.scroll.geometry = (528, 460) self.addWidget(self.scroll) self.startButton = Button('DATA/FormSave2/2SaveN.gi', '', 'DATA/FormSave2/2SaveD.gi') self.startButton.sounds = (self.buttonSounds[0], '', '') self.startButton.text = _('Start', 'FormLoadQuest.Start', 'OpenSR-World') self.startButton.font = self.buttonFont self.startButton.color = Color.fromString('#002842') self.startButton.position = (638, 574) self.startButton.layer = 1 self.startButton.addListener(self) self.addWidget(self.startButton) self.cancelButton = Button('DATA/FormSave2/2CancelN.gi', '', 'DATA/FormSave2/2CancelD.gi') self.cancelButton.sounds = (self.buttonSounds[0], '', '') self.cancelButton.text = _('Cancel', 'FormLoadQuest.Cancel', 'OpenSR-World') self.cancelButton.font = self.buttonFont self.cancelButton.color = Color.fromString('#002842') self.cancelButton.position = (638, 626) self.cancelButton.layer = 1 self.cancelButton.addListener(self) self.addWidget(self.cancelButton) self.closeButton = Button('DATA/FormSave2/2CloseN.gi', 'DATA/FormSave2/2CloseA.gi', 'DATA/FormSave2/2CloseD.gi') self.closeButton.sounds = self.buttonSounds self.closeButton.position = (891, 601) self.closeButton.layer = 1 self.closeButton.addListener(self) self.addWidget(self.closeButton) self.buttons = {} self.loadQuests() self.selected = None first = None i = 0 for q in self.quests: b = Button("DATA/FormLoadQuest/2SlotNormal.gi", "DATA/FormLoadQuest/2SlotOnMouse.gi", "DATA/FormLoadQuest/2SlotOnPress.gi") b.position = (0, 5 + i * (b.height + 5)) self.node.addWidget(b) self.buttons[b] = i b.addListener(self) if i == 0: first = b nl = Label(q.name) nl.font = self.font nl.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_CENTER) nl.position = (15, int(5 + i * (b.height + 5) + b.height / 2)) nl.layer = 1 nl.color = Color.fromString("#A5B68C") self.node.addChild(nl) if q.length < 1: diff = "DATA/FormLoadQuest/2D1.gi" elif q.length < 2: diff = "DATA/FormLoadQuest/2D2.gi" elif q.length < 3: diff = "DATA/FormLoadQuest/2D3.gi" elif q.length < 4: diff = "DATA/FormLoadQuest/2D4.gi" else: diff = "DATA/FormLoadQuest/2D5.gi" diffIcon = Sprite(diff) diffIcon.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_CENTER) diffIcon.position = (int(b.width / 2.2), int(5 + i * (b.height + 5) + b.height / 2)) diffIcon.layer = 1 self.node.addChild(diffIcon) gl = Label(q.genre) gl.font = self.smallFont gl.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_CENTER) gl.position = (int(b.width / 2.2) + 5 + diffIcon.width, int(5 + i * (b.height + 5) + b.height / 2)) gl.layer = 1 gl.color = Color.fromString("#A5B68C") gl.wordWrap = True gl.setFixedWidth(b.width - int(b.width / 2.2) - 5 - diffIcon.width) self.node.addChild(gl) i += 1 self.select(first) def select(self, button): if button == None: return if self.selected == button: return if self.selected != None: self.selected.removeListener(self) self.node.removeWidget(self.selected) i = self.buttons[self.selected] del self.buttons[self.selected] self.selected = Button("DATA/FormLoadQuest/2SlotNormal.gi", "DATA/FormLoadQuest/2SlotOnMouse.gi", "DATA/FormLoadQuest/2SlotOnPress.gi") self.selected.position = (0, 5 + i * (self.selected.height + 5)) self.node.addWidget(self.selected) self.selected.addListener(self) self.buttons[self.selected] = i button.removeListener(self) self.node.removeWidget(button) i = self.buttons[button] del self.buttons[button] self.selected = Button("DATA/FormLoadQuest/2SlotActive.gi") self.selected.position = (0, 5 + i * (self.selected.height + 5)) self.node.addWidget(self.selected) self.buttons[self.selected] = i self.selected.addListener(self) #if self.image != None: #self.removeChild(self.image) #self.image = Sprite(self.quests[i].image) #self.image.layer = -2 #self.image.position = (640, 15) #self.image.geometry = (200, 228) #self.addChild(self.image) self.selectedQuest = self.quests[i].id text = resources.datRoot()['PlanetQuest']['StartText'][self.quests[i].id].value text = text.replace("<Player>", '\\cS' + self.rangerName + '\\cR') text = text.replace("<CurPlanet>", '\\cS' + self.fromPlanet + '\\cR') text = text.replace("<CurStar>", '\\cS' + self.fromStar + '\\cR') text = text.replace("<ToPlanet>", '\\cS' + self.toPlanet + '\\cR') text = text.replace("<ToStar>", '\\cS' + self.toStar + '\\cR') text = text.replace("<FromPlanet>", '\\cS' + self.fromPlanet + '\\cR') text = text.replace("<FromStar>", '\\cS' + self.fromStar + '\\cR') self.desc.text = text self.descScroll.markToUpdate() def loadQuests(self): dat = resources.datRoot() self.rangerName = dat['FormLoadQuest']['PRanger'].value self.toPlanet = dat['FormLoadQuest']['PToPlanet'].value self.toStar = dat['FormLoadQuest']['PToStar'].value self.fromPlanet = dat['FormLoadQuest']['PFromPlanet'].value self.fromStar = dat['FormLoadQuest']['PFromStar'].value self.quests = [] for q in dat['PlanetQuest']['List']: info = QuestInfo() info.id = q.name info.name = q['Name'].value info.genre = q['Genre'].value info.group = int(q['Group'].value) info.access = int(q['Access'].value) info.length = int(q['Length'].value) info.image = getCacheDATPath(q['Image'].value) info.difficulty = int(q['Dif'].value) self.quests.append(info) def dispose(self): for k in self.buttons.keys(): k.removeListener(self) self.cancelButton.removeListener(self) self.startButton.removeListener(self) self.closeButton.removeListener(self) def processLogic(self, dt): ScriptWidget.processLogic(self, dt) def actionPerformed(self, action): if action.type != Action.Type.BUTTON_CLICKED: return if action.source in self.buttons: self.select(action.source) elif action.source == self.startButton: self.action(Action(self, Action.Type.DIALOG_ACCEPT)) elif action.source == self.cancelButton: self.action(Action(self, Action.Type.DIALOG_CANCEL)) elif action.source == self.closeButton: self.action(Action(self, Action.Type.DIALOG_CANCEL))
def __init__(self, questID): ScriptWidget.__init__(self) ActionListener.__init__(self) self.bg = Sprite("DATA/FormPQuest2/2BG.gi") self.addChild(self.bg) self.paramWindow = NinePatch("ORC/quest_param_win.9.json") self.paramWindow.position = (643, 457) self.paramWindow.geometry = (320, 280) self.addChild(self.paramWindow) self.exitButton = Button("DATA/FormPQuest2/2CloseN.gi", "DATA/FormPQuest2/2CloseA.gi", "DATA/FormPQuest2/2CloseD.gi") self.exitButton.position = (953, 725) self.addWidget(self.exitButton) self.exitButton.addListener(self) self.image = None self.questID = questID self.questFile = resources.datRoot( )['PlanetQuest']['PlanetQuest'][questID].value.replace('\\', '/') player.loadQuest(self.questFile) self.loadImages() self.style = resources.objectManager().getResourceObject( '/world/skin/quest/grey') self.interact = InteractionWidget(Rect(15, 45, 15 + 539, 45 + 363), Rect(15, 482, 15 + 539, 482 + 215), self.style) self.interact.position = (35, 5) self.interact.layer = -2 self.addWidget(self.interact) self.interact.addListener(self) self.paramLabel = ColorLabel("") self.paramLabel.wordWrap = True self.paramLabel.position = (665, 480) self.paramLabel.setFixedSize(280, 280) self.paramLabel.textColor = self.style.color self.paramLabel.selectionColor = self.style.activeColor self.addChild(self.paramLabel) self.skin1Button = Button("DATA/FormPQuest2/2Skin1N.gi", "DATA/FormPQuest2/2Skin1A.gi", "DATA/FormPQuest2/2Skin1D.gi") self.skin1Button.position = (529, 742) self.addWidget(self.skin1Button) self.skin1Button.addListener(self) self.skin2Button = Button("DATA/FormPQuest2/2Skin2N.gi", "DATA/FormPQuest2/2Skin2A.gi", "DATA/FormPQuest2/2Skin2D.gi") self.skin2Button.position = (547, 742) self.addWidget(self.skin2Button) self.skin2Button.addListener(self) self.skin3Button = Button("DATA/FormPQuest2/2Skin3N.gi", "DATA/FormPQuest2/2Skin3A.gi", "DATA/FormPQuest2/2Skin3D.gi") self.skin3Button.position = (565, 742) self.addWidget(self.skin3Button) self.skin3Button.addListener(self) self.skin4Button = Button("DATA/FormPQuest2/2Skin4N.gi", "DATA/FormPQuest2/2Skin4A.gi", "DATA/FormPQuest2/2Skin4D.gi") self.skin4Button.position = (583, 742) self.addWidget(self.skin4Button) self.skin4Button.addListener(self) self.updateWidget()
class QuestWidget(ScriptWidget, ActionListener): def __init__(self, questID): ScriptWidget.__init__(self) ActionListener.__init__(self) self.bg = Sprite("DATA/FormPQuest2/2BG.gi") self.addChild(self.bg) self.paramWindow = NinePatch("ORC/quest_param_win.9.json") self.paramWindow.position = (643, 457) self.paramWindow.geometry = (320, 280) self.addChild(self.paramWindow) self.exitButton = Button("DATA/FormPQuest2/2CloseN.gi", "DATA/FormPQuest2/2CloseA.gi", "DATA/FormPQuest2/2CloseD.gi") self.exitButton.position = (953, 725) self.addWidget(self.exitButton) self.exitButton.addListener(self) self.image = None self.questID = questID self.questFile = resources.datRoot()['PlanetQuest']['PlanetQuest'][questID].value.replace('\\', '/') player.loadQuest(self.questFile) self.loadImages() self.style = resources.objectManager().getResourceObject('/world/skin/quest/grey') self.interact = InteractionWidget(Rect(15, 45, 15 + 539, 45 + 363), Rect(15, 482, 15 + 539, 482 + 215), self.style) self.interact.position = (35, 5) self.interact.layer = -2; self.addWidget(self.interact) self.interact.addListener(self) self.paramLabel = ColorLabel("") self.paramLabel.wordWrap = True self.paramLabel.position = (665, 480) self.paramLabel.setFixedSize(280, 280) self.paramLabel.textColor = self.style.color self.paramLabel.selectionColor = self.style.activeColor self.addChild(self.paramLabel) self.skin1Button = Button("DATA/FormPQuest2/2Skin1N.gi", "DATA/FormPQuest2/2Skin1A.gi", "DATA/FormPQuest2/2Skin1D.gi") self.skin1Button.position = (529, 742) self.addWidget(self.skin1Button) self.skin1Button.addListener(self) self.skin2Button = Button("DATA/FormPQuest2/2Skin2N.gi", "DATA/FormPQuest2/2Skin2A.gi", "DATA/FormPQuest2/2Skin2D.gi") self.skin2Button.position = (547, 742) self.addWidget(self.skin2Button) self.skin2Button.addListener(self) self.skin3Button = Button("DATA/FormPQuest2/2Skin3N.gi", "DATA/FormPQuest2/2Skin3A.gi", "DATA/FormPQuest2/2Skin3D.gi") self.skin3Button.position = (565, 742) self.addWidget(self.skin3Button) self.skin3Button.addListener(self) self.skin4Button = Button("DATA/FormPQuest2/2Skin4N.gi", "DATA/FormPQuest2/2Skin4A.gi", "DATA/FormPQuest2/2Skin4D.gi") self.skin4Button.position = (583, 742) self.addWidget(self.skin4Button) self.skin4Button.addListener(self) self.updateWidget() def updateStyle(self): oldInteract = self.interact self.interact = InteractionWidget(Rect(15, 45, 15 + 539, 45 + 363), Rect(15, 482, 15 + 539, 482 + 215), self.style) self.interact.position = (35, 5) self.interact.layer = -2; self.addWidget(self.interact) self.interact.addListener(self) self.updateWidget() if oldInteract: oldInteract.removeListener(self) self.removeWidget(oldInteract) def updateWidget(self): self.selectionsID = [] text = player.currentText.replace("\r\n", "\n") if player.questCompleted: text = text + "\n\n\\c008000" + _("Quest completed!", "Planet.NotCivil.QuestPlay.MsgSuccess") + "\\cR" elif player.questFailed: text = text + "\n\n\\c800000" + _("Quest failed!", "Planet.NotCivil.QuestPlay.MsgFail") + "\\cR" if player.death: text = text + "\n\n\\c800000" + _("You're dead!", "Planet.NotCivil.QuestPlay.MsgDeath") + "\\cR" self.interact.text = text trans = player.visibleTransitions selections = [] for t in trans: self.selectionsID.append(t[0]) selections.append((t[1], t[2])) self.interact.selections = selections self.paramLabel.text = "\n".join(player.visibleParameters) newImage = getCacheDATPath(self.images[player.currentImage]) if newImage != "": if self.image: self.removeChild(self.image) self.image = Sprite(newImage) self.image.layer = -1 self.image.position = (656, 32) self.addChild(self.image) def loadImages(self): self.locImages = {} self.transImages = {} self.images = [] pqi = resources.datRoot()['Data']['PQI'] for r in pqi: v = r.name.split(',') if v[0] != self.questID: continue img = r.value imgID = len(self.images) self.images.append(img) if v[1] == "P" or v[1] == "PAR": for i in v[2:]: self.transImages[int(i)] = imgID else: for i in v[2:]: self.locImages[int(i)] = imgID player.setImages(self.locImages, self.transImages) def dispose(self): engine.removeWidget(self) self.skin1Button.removeListener(self) self.skin2Button.removeListener(self) self.skin3Button.removeListener(self) self.skin4Button.removeListener(self) self.interact.removeListener(self) self.exitButton.removeListener(self) def actionPerformed(self, action): if action.type >= Action.Type.USER and action.source == self.interact: index = action.type - Action.Type.USER player.transit(self.selectionsID[index]) self.updateWidget() if action.type == Action.Type.BUTTON_CLICKED: if action.source == self.exitButton: self.dispose() engine.addWidget(OpenSR.ORC.StartMenu.StartMenuWidget()) if action.source == self.skin1Button: self.style = resources.objectManager().getResourceObject('/world/skin/quest/grey') self.updateStyle() if action.source == self.skin2Button: self.style = resources.objectManager().getResourceObject('/world/skin/quest/dark') self.updateStyle() if action.source == self.skin3Button: self.style = resources.objectManager().getResourceObject('/world/skin/quest/light') self.updateStyle() if action.source == self.skin4Button: self.style = resources.objectManager().getResourceObject('/world/skin/quest/green') self.updateStyle()
def __init__(self): ScriptWidget.__init__(self) ActionListener.__init__(self) self.t = 0 self.bgforward = False self.background = Sprite('DATA/FormMain3/2bg.gi') self.background.width = self.background.width / (engine.screenHeight / self.background.height) self.background.height = engine.screenHeight self.background.layer = -3 self.addChild(self.background) self.bgPlanet = Sprite('DATA/FormMain3/2Planet.gi') self.bgPlanet.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_BOTTOM) self.bgPlanet.position = (0, engine.screenHeight) self.bgPlanet.layer = -2 self.addChild(self.bgPlanet) self.bgAnimLine = GAISprite("DATA/FormMain2/2AnimLine.gai") self.bgAnimLine.origin = (SpriteXOrigin.POSITION_X_RIGHT, SpriteYOrigin.POSITION_Y_TOP) self.bgAnimLine.position = (engine.screenWidth, 0) self.bgAnimLine.layer = 0 self.addChild(self.bgAnimLine) self.bgAnim = GAISprite("DATA/FormMain2/2AnimMain.gai") self.bgAnim.layer = -1 self.bgAnim.height = self.bgAnim.height * engine.screenWidth / self.bgAnim.width self.bgAnim.width = engine.screenWidth self.bgAnim.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_BOTTOM) self.bgAnim.position = (0, engine.screenHeight) self.addChild(self.bgAnim) self.caption = Sprite("DATA/FormMain3/2caption.gi") self.caption.origin = (SpriteXOrigin.POSITION_X_RIGHT, SpriteYOrigin.POSITION_Y_CENTER) self.caption.position = (engine.screenWidth, 110) self.caption.layer = 1 self.addChild(self.caption) self.ship = [None, None, None] self.ship[0] = GAISprite('DATA/FormMain3/2Ship1.gai') self.ship[0].position = (0, engine.screenHeight - self.ship[0].height) self.ship[0].layer = 1 self.ship[0].speed = 1.5 self.ship[0].singleShot = True self.ship[1] = GAISprite('DATA/FormMain3/2Ship2.gai') self.ship[1].position = (0, engine.screenHeight - self.ship[1].height) self.ship[1].layer = 1 self.ship[1].speed = 1.5 self.ship[1].singleShot = True self.ship[1].stop(); self.ship[2] = GAISprite('DATA/FormMain3/2Ship3.gai') self.ship[2].position = (0, engine.screenHeight - self.ship[2].height) self.ship[2].layer = 1 self.ship[2].speed = 1.5 self.ship[2].singleShot = True self.ship[2].stop(); self.addChild(self.ship[0]) self.currentShip = 0 self.menuNode = WidgetNode() self.menuNode.layer = 2 self.menuNode.position = (engine.screenWidth - 400, 300) self.addWidget(self.menuNode) sound.playMusic("Music/SPECIAL/SpaceIsCalling.dat", False) self.buttons = {} clickSound = "Sound/ButtonClick.wav" leaveSound = "Sound/ButtonLeave.WAV" enterSound = "Sound/ButtonEnter.wav" y = 0 for name in self.BUTTONS: button = Button('DATA/FormMain2/' + self.BUTTON_FILES[name] + 'N.gi', 'DATA/FormMain2/' + self.BUTTON_FILES[name] + 'A.gi', 'DATA/FormMain2/' + self.BUTTON_FILES[name] + 'D.gi') self.buttons[name] = button button.addListener(self) button.position = (0, y) button.sounds = (clickSound, enterSound, leaveSound) self.menuNode.addWidget(button) y = y + self.BUTTON_SPARSE self.questButton = Button('DATA/FormLoadRobot/2LoadQuestN.gi', 'DATA/FormLoadRobot/2LoadQuestA.gi', 'DATA/FormLoadRobot/2LoadQuestN.gi') self.questButton.addListener(self) self.questButton.position = (305, engine.screenHeight - 135) self.questButton.layer = 2 self.questButton.sounds = (clickSound, enterSound, leaveSound) self.addWidget(self.questButton) self.pause = False
class StartMenuWidget(ScriptWidget, ActionListener): BG_SPEED = 20.0 / 1000.0 BUTTON_FILES = {'newGame': '2ButNew', 'loadGame': '2ButLoad', 'settings': '2ButSettings', 'records': '2ButRecords', 'about': '2ButAbout', 'exit': '2ButExit'} BUTTONS = ['newGame', 'loadGame', 'settings', 'records', 'about', 'exit'] BUTTON_SPARSE = 60 def __init__(self): ScriptWidget.__init__(self) ActionListener.__init__(self) self.t = 0 self.bgforward = False self.background = Sprite('DATA/FormMain3/2bg.gi') self.background.width = self.background.width / (engine.screenHeight / self.background.height) self.background.height = engine.screenHeight self.background.layer = -3 self.addChild(self.background) self.bgPlanet = Sprite('DATA/FormMain3/2Planet.gi') self.bgPlanet.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_BOTTOM) self.bgPlanet.position = (0, engine.screenHeight) self.bgPlanet.layer = -2 self.addChild(self.bgPlanet) self.bgAnimLine = GAISprite("DATA/FormMain2/2AnimLine.gai") self.bgAnimLine.origin = (SpriteXOrigin.POSITION_X_RIGHT, SpriteYOrigin.POSITION_Y_TOP) self.bgAnimLine.position = (engine.screenWidth, 0) self.bgAnimLine.layer = 0 self.addChild(self.bgAnimLine) self.bgAnim = GAISprite("DATA/FormMain2/2AnimMain.gai") self.bgAnim.layer = -1 self.bgAnim.height = self.bgAnim.height * engine.screenWidth / self.bgAnim.width self.bgAnim.width = engine.screenWidth self.bgAnim.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_BOTTOM) self.bgAnim.position = (0, engine.screenHeight) self.addChild(self.bgAnim) self.caption = Sprite("DATA/FormMain3/2caption.gi") self.caption.origin = (SpriteXOrigin.POSITION_X_RIGHT, SpriteYOrigin.POSITION_Y_CENTER) self.caption.position = (engine.screenWidth, 110) self.caption.layer = 1 self.addChild(self.caption) self.ship = [None, None, None] self.ship[0] = GAISprite('DATA/FormMain3/2Ship1.gai') self.ship[0].position = (0, engine.screenHeight - self.ship[0].height) self.ship[0].layer = 1 self.ship[0].speed = 1.5 self.ship[0].singleShot = True self.ship[1] = GAISprite('DATA/FormMain3/2Ship2.gai') self.ship[1].position = (0, engine.screenHeight - self.ship[1].height) self.ship[1].layer = 1 self.ship[1].speed = 1.5 self.ship[1].singleShot = True self.ship[1].stop(); self.ship[2] = GAISprite('DATA/FormMain3/2Ship3.gai') self.ship[2].position = (0, engine.screenHeight - self.ship[2].height) self.ship[2].layer = 1 self.ship[2].speed = 1.5 self.ship[2].singleShot = True self.ship[2].stop(); self.addChild(self.ship[0]) self.currentShip = 0 self.menuNode = WidgetNode() self.menuNode.layer = 2 self.menuNode.position = (engine.screenWidth - 400, 300) self.addWidget(self.menuNode) sound.playMusic("Music/SPECIAL/SpaceIsCalling.dat", False) self.buttons = {} clickSound = "Sound/ButtonClick.wav" leaveSound = "Sound/ButtonLeave.WAV" enterSound = "Sound/ButtonEnter.wav" y = 0 for name in self.BUTTONS: button = Button('DATA/FormMain2/' + self.BUTTON_FILES[name] + 'N.gi', 'DATA/FormMain2/' + self.BUTTON_FILES[name] + 'A.gi', 'DATA/FormMain2/' + self.BUTTON_FILES[name] + 'D.gi') self.buttons[name] = button button.addListener(self) button.position = (0, y) button.sounds = (clickSound, enterSound, leaveSound) self.menuNode.addWidget(button) y = y + self.BUTTON_SPARSE self.questButton = Button('DATA/FormLoadRobot/2LoadQuestN.gi', 'DATA/FormLoadRobot/2LoadQuestA.gi', 'DATA/FormLoadRobot/2LoadQuestN.gi') self.questButton.addListener(self) self.questButton.position = (305, engine.screenHeight - 135) self.questButton.layer = 2 self.questButton.sounds = (clickSound, enterSound, leaveSound) self.addWidget(self.questButton) self.pause = False def processLogic(self, dt): if self.pause: return ScriptWidget.processLogic(self, dt) if math.fabs(self.t * self.BG_SPEED) >= self.background.width - engine.screenWidth: self.t = 0 self.bgforward = not self.bgforward if self.bgforward: self.background.position = (- self.t * self.BG_SPEED, 0) else: self.background.position = (- self.background.width + engine.screenWidth + self.t * self.BG_SPEED, 0) if not self.ship[self.currentShip].started: self.removeChild(self.ship[self.currentShip]) self.currentShip = (self.currentShip + 1) % 3 self.addChild(self.ship[self.currentShip]) self.ship[self.currentShip].reset() self.ship[self.currentShip].start() self.t = self.t + dt def dispose(self): engine.removeWidget(self) for name in self.BUTTONS: self.buttons[name].removeListener(self) self.questButton.removeListener(self) def openGame(self): widget = SystemWidget(world.systemManager().currentSystem) engine.addWidget(widget) self.dispose() def startQuest(self, questFile): widget = QuestWidget(questFile) engine.addWidget(widget) self.dispose() def actionPerformed(self, action): if action.type == Action.Type.BUTTON_CLICKED: if action.source == self.buttons['exit']: self.dispose() engine.quit(0) elif action.source == self.buttons['settings']: self.dispose() engine.addWidget(OpenSR.ORC.Settings.SettingsWidget()) elif action.source == self.buttons['newGame']: world.addGenHook(WorldGen()) world.generateWorld() world.saveWorld('test.srw') self.openGame() elif action.source == self.buttons['loadGame']: world.loadWorld('test.srw') self.openGame() elif action.source == self.questButton: self.pause = True self.questDialog = OpenSR.ORC.QuestSelectionWidget.QuestSelectionWidget() self.questDialog.layer = 4 self.questDialog.position = (int((engine.screenWidth - self.questDialog.width) / 2), int((engine.screenHeight - self.questDialog.height) / 2)) self.questDialog.addListener(self) engine.addWidget(self.questDialog) if action.type == Action.Type.DIALOG_ACCEPT: if action.source == self.questDialog: self.pause = False self.questDialog.dispose() self.questDialog.removeListener(self) engine.removeWidget(self.questDialog) quest = self.questDialog.selectedQuest del self.questDialog self.startQuest(quest) elif action.type == Action.Type.DIALOG_CANCEL: if action.source == self.questDialog: self.pause = False self.questDialog.dispose() self.questDialog.removeListener(self) engine.removeWidget(self.questDialog) del self.questDialog
def __init__(self): ScriptWidget.__init__(self) ActionListener.__init__(self) self.background = Sprite("DATA/FormOptions2/2Bg.gi") self.background.width = engine.screenWidth self.background.height = engine.screenHeight self.background.layer = -2 self.addChild(self.background) deltaY = engine.screenHeight - 768 deltaX = engine.screenWidth - 1024 self.formBg = NinePatch("ORC/settings_bg.9.json") self.formBg.geometry = (self.formBg.width + deltaX, self.formBg.height + deltaY) self.formBg.position = (math.floor((engine.screenWidth - self.formBg.width) / 2) - 10, 32) self.formBg.layer = -1 self.addChild(self.formBg) self.formTop = NinePatch("ORC/settings_top.9.json") self.formTop.width = self.formTop.width + deltaX self.formTop.position = (math.floor((engine.screenWidth - self.formTop.width) / 2), 0) self.formTop.layer = -1 self.addChild(self.formTop) self.formBottom = NinePatch("ORC/settings_bottom.9.json") self.formBottom.width = self.formBottom.width + deltaX self.formBottom.position = (math.floor((engine.screenWidth - self.formTop.width) / 2), engine.screenHeight - self.formBottom.height) self.formBottom.layer = -1 self.addChild(self.formBottom) self.buttonNode = WidgetNode() self.buttonNode.position = (self.formBg.position.x + 80, self.formBg.position.y + 120) self.addWidget(self.buttonNode) self.spaceButton = Button("DATA/FormOptions2/2SpaceN.gi", "DATA/FormOptions2/2SpaceN.gi", "DATA/FormOptions2/2SpaceD.gi") self.spaceButton.position = (self.formBg.position.x + 26, self.formBg.position.y + 10) self.addWidget(self.spaceButton) self.okButton = Button("DATA/FormOptions2/2OkN.gi", "DATA/FormOptions2/2OkA.gi", "DATA/FormOptions2/2OkD.gi") self.okButton.position = (self.formBottom.position.x + 607 + deltaX, self.formBottom.position.y + 22) self.okButton.addListener(self) self.setSoundsDefault(self.okButton) self.addWidget(self.okButton) self.cancelButton = Button("DATA/FormOptions2/2CancelN.gi", "DATA/FormOptions2/2CancelA.gi", "DATA/FormOptions2/2CancelD.gi") self.cancelButton.position = (self.formBottom.position.x + 674 + deltaX, self.formBottom.position.y + 22) self.cancelButton.addListener(self) self.setSoundsDefault(self.cancelButton) self.addWidget(self.cancelButton) self.autoButton = Button("DATA/FormOptions2/2AutoN.gi", "DATA/FormOptions2/2AutoA.gi", "DATA/FormOptions2/2AutoD.gi") self.autoButton.position = (self.formBottom.position.x + 102, self.formBottom.position.y + 22) self.setSoundsDefault(self.autoButton) self.addWidget(self.autoButton) self.highButton = Button("DATA/FormOptions2/2HighN.gi", "DATA/FormOptions2/2HighA.gi", "DATA/FormOptions2/2HighD.gi") self.highButton.position = (self.formBottom.position.x + 176, self.formBottom.position.y + 4) self.setSoundsDefault(self.highButton) self.addWidget(self.highButton) self.mediumButton = Button("DATA/FormOptions2/2MediumN.gi", "DATA/FormOptions2/2MediumA.gi", "DATA/FormOptions2/2MediumD.gi") self.mediumButton.position = (self.formBottom.position.x + 170, self.formBottom.position.y + 33) self.setSoundsDefault(self.mediumButton) self.addWidget(self.mediumButton) self.lowButton = Button("DATA/FormOptions2/2LowN.gi", "DATA/FormOptions2/2LowA.gi", "DATA/FormOptions2/2LowD.gi") self.lowButton.position = (self.formBottom.position.x + 161, self.formBottom.position.y + 58) self.setSoundsDefault(self.lowButton) self.addWidget(self.lowButton) self.graphicsButton = Button("DATA/FormOptions2/2PageN.gi", "DATA/FormOptions2/2PageA.gi", "DATA/FormOptions2/2PageD.gi") self.graphicsButton.font = engine.coreFont self.graphicsButton.text = _("Graphics", "FormCfgSettings.GGraph") self.graphicsButton.color = Color(0.75, 0.85, 1.0) self.graphicsButton.position = (0, 0) self.setSoundsDefault(self.graphicsButton) self.buttonNode.addWidget(self.graphicsButton) self.paramNode = WidgetNode() self.widthLabel = Label(_("Width:")) self.paramNode.addChild(self.widthLabel) self.widthEdit = LineEdit(engine.defaultSkin.lineEditStyle) self.paramNode.addWidget(self.widthEdit) self.heightLabel = Label(_("Height:")) self.paramNode.addChild(self.heightLabel) self.heightEdit = LineEdit(engine.defaultSkin.lineEditStyle) self.paramNode.addWidget(self.heightEdit) self.fullscreen = CheckBox(engine.defaultSkin.checkBoxStyle, _("Fullscreen mode")) self.paramNode.addWidget(self.fullscreen) self.useShaders = CheckBox(engine.defaultSkin.checkBoxStyle, _("Use shaders")) self.paramNode.addWidget(self.useShaders) self.widthEdit.width = 50 self.widthEdit.position = (100, 5) self.widthLabel.position = (5, 5 + (self.widthEdit.height - self.widthLabel.font.size)) self.heightEdit.width = 50 self.heightEdit.position = (270, 5) self.heightLabel.position = (170, 5 + (self.widthEdit.height - self.widthLabel.font.size)) self.fullscreen.position = (5, self.widthEdit.height + 15) self.useShaders.position = (5, self.fullscreen.position.y + self.fullscreen.height + 5) self.scroll = ScrollArea(engine.defaultSkin.scrollStyle, self.paramNode) self.scroll.position = (self.formBg.position.x + 257, self.formBg.position.y + 149) self.scroll.geometry = (426 + deltaX, 439 + deltaY) self.addWidget(self.scroll) # RadioButton example #self.group = OpenSR.Engine.RadioButtonGroup() #self.r1 = OpenSR.Engine.RadioButton(engine.defaultSkin().radioButtonStyle, "Yes") #self.r2 = OpenSR.Engine.RadioButton(engine.defaultSkin().radioButtonStyle, "No") #self.r3 = OpenSR.Engine.RadioButton(engine.defaultSkin().radioButtonStyle, "I dunno lol") #self.r2.setPosition(0, self.r1.height + 5) #self.r3.setPosition(0, self.r2.position.y + self.r2.height + 5) #self.group.addRadioButton(self.r1) #self.group.addRadioButton(self.r2) #self.group.addRadioButton(self.r3) #self.group.setPosition(0, 300) #self.paramNode.addWidget(self.group) self.loadSettings()
class SettingsWidget(ScriptWidget, ActionListener): def __init__(self): ScriptWidget.__init__(self) ActionListener.__init__(self) self.background = Sprite("DATA/FormOptions2/2Bg.gi") self.background.width = engine.screenWidth self.background.height = engine.screenHeight self.background.layer = -2 self.addChild(self.background) deltaY = engine.screenHeight - 768 deltaX = engine.screenWidth - 1024 self.formBg = NinePatch("ORC/settings_bg.9.json") self.formBg.geometry = (self.formBg.width + deltaX, self.formBg.height + deltaY) self.formBg.position = (math.floor((engine.screenWidth - self.formBg.width) / 2) - 10, 32) self.formBg.layer = -1 self.addChild(self.formBg) self.formTop = NinePatch("ORC/settings_top.9.json") self.formTop.width = self.formTop.width + deltaX self.formTop.position = (math.floor((engine.screenWidth - self.formTop.width) / 2), 0) self.formTop.layer = -1 self.addChild(self.formTop) self.formBottom = NinePatch("ORC/settings_bottom.9.json") self.formBottom.width = self.formBottom.width + deltaX self.formBottom.position = (math.floor((engine.screenWidth - self.formTop.width) / 2), engine.screenHeight - self.formBottom.height) self.formBottom.layer = -1 self.addChild(self.formBottom) self.buttonNode = WidgetNode() self.buttonNode.position = (self.formBg.position.x + 80, self.formBg.position.y + 120) self.addWidget(self.buttonNode) self.spaceButton = Button("DATA/FormOptions2/2SpaceN.gi", "DATA/FormOptions2/2SpaceN.gi", "DATA/FormOptions2/2SpaceD.gi") self.spaceButton.position = (self.formBg.position.x + 26, self.formBg.position.y + 10) self.addWidget(self.spaceButton) self.okButton = Button("DATA/FormOptions2/2OkN.gi", "DATA/FormOptions2/2OkA.gi", "DATA/FormOptions2/2OkD.gi") self.okButton.position = (self.formBottom.position.x + 607 + deltaX, self.formBottom.position.y + 22) self.okButton.addListener(self) self.setSoundsDefault(self.okButton) self.addWidget(self.okButton) self.cancelButton = Button("DATA/FormOptions2/2CancelN.gi", "DATA/FormOptions2/2CancelA.gi", "DATA/FormOptions2/2CancelD.gi") self.cancelButton.position = (self.formBottom.position.x + 674 + deltaX, self.formBottom.position.y + 22) self.cancelButton.addListener(self) self.setSoundsDefault(self.cancelButton) self.addWidget(self.cancelButton) self.autoButton = Button("DATA/FormOptions2/2AutoN.gi", "DATA/FormOptions2/2AutoA.gi", "DATA/FormOptions2/2AutoD.gi") self.autoButton.position = (self.formBottom.position.x + 102, self.formBottom.position.y + 22) self.setSoundsDefault(self.autoButton) self.addWidget(self.autoButton) self.highButton = Button("DATA/FormOptions2/2HighN.gi", "DATA/FormOptions2/2HighA.gi", "DATA/FormOptions2/2HighD.gi") self.highButton.position = (self.formBottom.position.x + 176, self.formBottom.position.y + 4) self.setSoundsDefault(self.highButton) self.addWidget(self.highButton) self.mediumButton = Button("DATA/FormOptions2/2MediumN.gi", "DATA/FormOptions2/2MediumA.gi", "DATA/FormOptions2/2MediumD.gi") self.mediumButton.position = (self.formBottom.position.x + 170, self.formBottom.position.y + 33) self.setSoundsDefault(self.mediumButton) self.addWidget(self.mediumButton) self.lowButton = Button("DATA/FormOptions2/2LowN.gi", "DATA/FormOptions2/2LowA.gi", "DATA/FormOptions2/2LowD.gi") self.lowButton.position = (self.formBottom.position.x + 161, self.formBottom.position.y + 58) self.setSoundsDefault(self.lowButton) self.addWidget(self.lowButton) self.graphicsButton = Button("DATA/FormOptions2/2PageN.gi", "DATA/FormOptions2/2PageA.gi", "DATA/FormOptions2/2PageD.gi") self.graphicsButton.font = engine.coreFont self.graphicsButton.text = _("Graphics", "FormCfgSettings.GGraph") self.graphicsButton.color = Color(0.75, 0.85, 1.0) self.graphicsButton.position = (0, 0) self.setSoundsDefault(self.graphicsButton) self.buttonNode.addWidget(self.graphicsButton) self.paramNode = WidgetNode() self.widthLabel = Label(_("Width:")) self.paramNode.addChild(self.widthLabel) self.widthEdit = LineEdit(engine.defaultSkin.lineEditStyle) self.paramNode.addWidget(self.widthEdit) self.heightLabel = Label(_("Height:")) self.paramNode.addChild(self.heightLabel) self.heightEdit = LineEdit(engine.defaultSkin.lineEditStyle) self.paramNode.addWidget(self.heightEdit) self.fullscreen = CheckBox(engine.defaultSkin.checkBoxStyle, _("Fullscreen mode")) self.paramNode.addWidget(self.fullscreen) self.useShaders = CheckBox(engine.defaultSkin.checkBoxStyle, _("Use shaders")) self.paramNode.addWidget(self.useShaders) self.widthEdit.width = 50 self.widthEdit.position = (100, 5) self.widthLabel.position = (5, 5 + (self.widthEdit.height - self.widthLabel.font.size)) self.heightEdit.width = 50 self.heightEdit.position = (270, 5) self.heightLabel.position = (170, 5 + (self.widthEdit.height - self.widthLabel.font.size)) self.fullscreen.position = (5, self.widthEdit.height + 15) self.useShaders.position = (5, self.fullscreen.position.y + self.fullscreen.height + 5) self.scroll = ScrollArea(engine.defaultSkin.scrollStyle, self.paramNode) self.scroll.position = (self.formBg.position.x + 257, self.formBg.position.y + 149) self.scroll.geometry = (426 + deltaX, 439 + deltaY) self.addWidget(self.scroll) # RadioButton example #self.group = OpenSR.Engine.RadioButtonGroup() #self.r1 = OpenSR.Engine.RadioButton(engine.defaultSkin().radioButtonStyle, "Yes") #self.r2 = OpenSR.Engine.RadioButton(engine.defaultSkin().radioButtonStyle, "No") #self.r3 = OpenSR.Engine.RadioButton(engine.defaultSkin().radioButtonStyle, "I dunno lol") #self.r2.setPosition(0, self.r1.height + 5) #self.r3.setPosition(0, self.r2.position.y + self.r2.height + 5) #self.group.addRadioButton(self.r1) #self.group.addRadioButton(self.r2) #self.group.addRadioButton(self.r3) #self.group.setPosition(0, 300) #self.paramNode.addWidget(self.group) self.loadSettings() def loadSettings(self): self.widthEdit.text = str(engine.propertiesGetInt("graphics.width", 1024)) self.heightEdit.text = str(engine.propertiesGetInt("graphics.height", 768)) self.fullscreen.checked = engine.propertiesGetBool("graphics.fullscreen", False) self.useShaders.checked = engine.propertiesGetBool("graphics.useShaders", True) def saveSettings(self): width = int(self.widthEdit.text) height = int(self.heightEdit.text) fs = self.fullscreen.checked shader = self.useShaders.checked engine.propertiesSetInt("graphics.width", width) engine.propertiesSetInt("graphics.height", height) engine.propertiesSetBool("graphics.fullscreen", fs) engine.propertiesSetBool("graphics.useShaders", shader) def dispose(self): engine.removeWidget(self) self.cancelButton.removeListener(self) self.okButton.removeListener(self) def actionPerformed(self, action): if action.type != Action.Type.BUTTON_CLICKED: return if action.source == self.okButton: self.saveSettings() self.dispose() engine.addWidget(OpenSR.ORC.StartMenu.StartMenuWidget()) def setSoundsDefault(self, button): clickSound = sound.loadSound("Sound/ButtonClick.wav") leaveSound = sound.loadSound("Sound/ButtonLeave.WAV") enterSound = sound.loadSound("Sound/ButtonEnter.wav") button.sounds = (clickSound, leaveSound, enterSound)
def __init__(self): ScriptWidget.__init__(self) ActionListener.__init__(self) self.background = Sprite("DATA/FormOptions2/2Bg.gi") self.background.width = engine.screenWidth self.background.height = engine.screenHeight self.background.layer = -2 self.addChild(self.background) deltaY = engine.screenHeight - 768 deltaX = engine.screenWidth - 1024 self.formBg = NinePatch("ORC/settings_bg.9.json") self.formBg.geometry = (self.formBg.width + deltaX, self.formBg.height + deltaY) self.formBg.position = (math.floor( (engine.screenWidth - self.formBg.width) / 2) - 10, 32) self.formBg.layer = -1 self.addChild(self.formBg) self.formTop = NinePatch("ORC/settings_top.9.json") self.formTop.width = self.formTop.width + deltaX self.formTop.position = (math.floor( (engine.screenWidth - self.formTop.width) / 2), 0) self.formTop.layer = -1 self.addChild(self.formTop) self.formBottom = NinePatch("ORC/settings_bottom.9.json") self.formBottom.width = self.formBottom.width + deltaX self.formBottom.position = (math.floor( (engine.screenWidth - self.formTop.width) / 2), engine.screenHeight - self.formBottom.height) self.formBottom.layer = -1 self.addChild(self.formBottom) self.buttonNode = WidgetNode() self.buttonNode.position = (self.formBg.position.x + 80, self.formBg.position.y + 120) self.addWidget(self.buttonNode) self.spaceButton = Button("DATA/FormOptions2/2SpaceN.gi", "DATA/FormOptions2/2SpaceN.gi", "DATA/FormOptions2/2SpaceD.gi") self.spaceButton.position = (self.formBg.position.x + 26, self.formBg.position.y + 10) self.addWidget(self.spaceButton) self.okButton = Button("DATA/FormOptions2/2OkN.gi", "DATA/FormOptions2/2OkA.gi", "DATA/FormOptions2/2OkD.gi") self.okButton.position = (self.formBottom.position.x + 607 + deltaX, self.formBottom.position.y + 22) self.okButton.addListener(self) self.setSoundsDefault(self.okButton) self.addWidget(self.okButton) self.cancelButton = Button("DATA/FormOptions2/2CancelN.gi", "DATA/FormOptions2/2CancelA.gi", "DATA/FormOptions2/2CancelD.gi") self.cancelButton.position = (self.formBottom.position.x + 674 + deltaX, self.formBottom.position.y + 22) self.cancelButton.addListener(self) self.setSoundsDefault(self.cancelButton) self.addWidget(self.cancelButton) self.autoButton = Button("DATA/FormOptions2/2AutoN.gi", "DATA/FormOptions2/2AutoA.gi", "DATA/FormOptions2/2AutoD.gi") self.autoButton.position = (self.formBottom.position.x + 102, self.formBottom.position.y + 22) self.setSoundsDefault(self.autoButton) self.addWidget(self.autoButton) self.highButton = Button("DATA/FormOptions2/2HighN.gi", "DATA/FormOptions2/2HighA.gi", "DATA/FormOptions2/2HighD.gi") self.highButton.position = (self.formBottom.position.x + 176, self.formBottom.position.y + 4) self.setSoundsDefault(self.highButton) self.addWidget(self.highButton) self.mediumButton = Button("DATA/FormOptions2/2MediumN.gi", "DATA/FormOptions2/2MediumA.gi", "DATA/FormOptions2/2MediumD.gi") self.mediumButton.position = (self.formBottom.position.x + 170, self.formBottom.position.y + 33) self.setSoundsDefault(self.mediumButton) self.addWidget(self.mediumButton) self.lowButton = Button("DATA/FormOptions2/2LowN.gi", "DATA/FormOptions2/2LowA.gi", "DATA/FormOptions2/2LowD.gi") self.lowButton.position = (self.formBottom.position.x + 161, self.formBottom.position.y + 58) self.setSoundsDefault(self.lowButton) self.addWidget(self.lowButton) self.graphicsButton = Button("DATA/FormOptions2/2PageN.gi", "DATA/FormOptions2/2PageA.gi", "DATA/FormOptions2/2PageD.gi") self.graphicsButton.font = engine.coreFont self.graphicsButton.text = _("Graphics", "FormCfgSettings.GGraph") self.graphicsButton.color = Color(0.75, 0.85, 1.0) self.graphicsButton.position = (0, 0) self.setSoundsDefault(self.graphicsButton) self.buttonNode.addWidget(self.graphicsButton) self.paramNode = WidgetNode() self.widthLabel = Label(_("Width:")) self.paramNode.addChild(self.widthLabel) self.widthEdit = LineEdit(engine.defaultSkin.lineEditStyle) self.paramNode.addWidget(self.widthEdit) self.heightLabel = Label(_("Height:")) self.paramNode.addChild(self.heightLabel) self.heightEdit = LineEdit(engine.defaultSkin.lineEditStyle) self.paramNode.addWidget(self.heightEdit) self.fullscreen = CheckBox(engine.defaultSkin.checkBoxStyle, _("Fullscreen mode")) self.paramNode.addWidget(self.fullscreen) self.useShaders = CheckBox(engine.defaultSkin.checkBoxStyle, _("Use shaders")) self.paramNode.addWidget(self.useShaders) self.widthEdit.width = 50 self.widthEdit.position = (100, 5) self.widthLabel.position = ( 5, 5 + (self.widthEdit.height - self.widthLabel.font.size)) self.heightEdit.width = 50 self.heightEdit.position = (270, 5) self.heightLabel.position = ( 170, 5 + (self.widthEdit.height - self.widthLabel.font.size)) self.fullscreen.position = (5, self.widthEdit.height + 15) self.useShaders.position = (5, self.fullscreen.position.y + self.fullscreen.height + 5) self.scroll = ScrollArea(engine.defaultSkin.scrollStyle, self.paramNode) self.scroll.position = (self.formBg.position.x + 257, self.formBg.position.y + 149) self.scroll.geometry = (426 + deltaX, 439 + deltaY) self.addWidget(self.scroll) # RadioButton example #self.group = OpenSR.Engine.RadioButtonGroup() #self.r1 = OpenSR.Engine.RadioButton(engine.defaultSkin().radioButtonStyle, "Yes") #self.r2 = OpenSR.Engine.RadioButton(engine.defaultSkin().radioButtonStyle, "No") #self.r3 = OpenSR.Engine.RadioButton(engine.defaultSkin().radioButtonStyle, "I dunno lol") #self.r2.setPosition(0, self.r1.height + 5) #self.r3.setPosition(0, self.r2.position.y + self.r2.height + 5) #self.group.addRadioButton(self.r1) #self.group.addRadioButton(self.r2) #self.group.addRadioButton(self.r3) #self.group.setPosition(0, 300) #self.paramNode.addWidget(self.group) self.loadSettings()
class SettingsWidget(ScriptWidget, ActionListener): def __init__(self): ScriptWidget.__init__(self) ActionListener.__init__(self) self.background = Sprite("DATA/FormOptions2/2Bg.gi") self.background.width = engine.screenWidth self.background.height = engine.screenHeight self.background.layer = -2 self.addChild(self.background) deltaY = engine.screenHeight - 768 deltaX = engine.screenWidth - 1024 self.formBg = NinePatch("ORC/settings_bg.9.json") self.formBg.geometry = (self.formBg.width + deltaX, self.formBg.height + deltaY) self.formBg.position = (math.floor( (engine.screenWidth - self.formBg.width) / 2) - 10, 32) self.formBg.layer = -1 self.addChild(self.formBg) self.formTop = NinePatch("ORC/settings_top.9.json") self.formTop.width = self.formTop.width + deltaX self.formTop.position = (math.floor( (engine.screenWidth - self.formTop.width) / 2), 0) self.formTop.layer = -1 self.addChild(self.formTop) self.formBottom = NinePatch("ORC/settings_bottom.9.json") self.formBottom.width = self.formBottom.width + deltaX self.formBottom.position = (math.floor( (engine.screenWidth - self.formTop.width) / 2), engine.screenHeight - self.formBottom.height) self.formBottom.layer = -1 self.addChild(self.formBottom) self.buttonNode = WidgetNode() self.buttonNode.position = (self.formBg.position.x + 80, self.formBg.position.y + 120) self.addWidget(self.buttonNode) self.spaceButton = Button("DATA/FormOptions2/2SpaceN.gi", "DATA/FormOptions2/2SpaceN.gi", "DATA/FormOptions2/2SpaceD.gi") self.spaceButton.position = (self.formBg.position.x + 26, self.formBg.position.y + 10) self.addWidget(self.spaceButton) self.okButton = Button("DATA/FormOptions2/2OkN.gi", "DATA/FormOptions2/2OkA.gi", "DATA/FormOptions2/2OkD.gi") self.okButton.position = (self.formBottom.position.x + 607 + deltaX, self.formBottom.position.y + 22) self.okButton.addListener(self) self.setSoundsDefault(self.okButton) self.addWidget(self.okButton) self.cancelButton = Button("DATA/FormOptions2/2CancelN.gi", "DATA/FormOptions2/2CancelA.gi", "DATA/FormOptions2/2CancelD.gi") self.cancelButton.position = (self.formBottom.position.x + 674 + deltaX, self.formBottom.position.y + 22) self.cancelButton.addListener(self) self.setSoundsDefault(self.cancelButton) self.addWidget(self.cancelButton) self.autoButton = Button("DATA/FormOptions2/2AutoN.gi", "DATA/FormOptions2/2AutoA.gi", "DATA/FormOptions2/2AutoD.gi") self.autoButton.position = (self.formBottom.position.x + 102, self.formBottom.position.y + 22) self.setSoundsDefault(self.autoButton) self.addWidget(self.autoButton) self.highButton = Button("DATA/FormOptions2/2HighN.gi", "DATA/FormOptions2/2HighA.gi", "DATA/FormOptions2/2HighD.gi") self.highButton.position = (self.formBottom.position.x + 176, self.formBottom.position.y + 4) self.setSoundsDefault(self.highButton) self.addWidget(self.highButton) self.mediumButton = Button("DATA/FormOptions2/2MediumN.gi", "DATA/FormOptions2/2MediumA.gi", "DATA/FormOptions2/2MediumD.gi") self.mediumButton.position = (self.formBottom.position.x + 170, self.formBottom.position.y + 33) self.setSoundsDefault(self.mediumButton) self.addWidget(self.mediumButton) self.lowButton = Button("DATA/FormOptions2/2LowN.gi", "DATA/FormOptions2/2LowA.gi", "DATA/FormOptions2/2LowD.gi") self.lowButton.position = (self.formBottom.position.x + 161, self.formBottom.position.y + 58) self.setSoundsDefault(self.lowButton) self.addWidget(self.lowButton) self.graphicsButton = Button("DATA/FormOptions2/2PageN.gi", "DATA/FormOptions2/2PageA.gi", "DATA/FormOptions2/2PageD.gi") self.graphicsButton.font = engine.coreFont self.graphicsButton.text = _("Graphics", "FormCfgSettings.GGraph") self.graphicsButton.color = Color(0.75, 0.85, 1.0) self.graphicsButton.position = (0, 0) self.setSoundsDefault(self.graphicsButton) self.buttonNode.addWidget(self.graphicsButton) self.paramNode = WidgetNode() self.widthLabel = Label(_("Width:")) self.paramNode.addChild(self.widthLabel) self.widthEdit = LineEdit(engine.defaultSkin.lineEditStyle) self.paramNode.addWidget(self.widthEdit) self.heightLabel = Label(_("Height:")) self.paramNode.addChild(self.heightLabel) self.heightEdit = LineEdit(engine.defaultSkin.lineEditStyle) self.paramNode.addWidget(self.heightEdit) self.fullscreen = CheckBox(engine.defaultSkin.checkBoxStyle, _("Fullscreen mode")) self.paramNode.addWidget(self.fullscreen) self.useShaders = CheckBox(engine.defaultSkin.checkBoxStyle, _("Use shaders")) self.paramNode.addWidget(self.useShaders) self.widthEdit.width = 50 self.widthEdit.position = (100, 5) self.widthLabel.position = ( 5, 5 + (self.widthEdit.height - self.widthLabel.font.size)) self.heightEdit.width = 50 self.heightEdit.position = (270, 5) self.heightLabel.position = ( 170, 5 + (self.widthEdit.height - self.widthLabel.font.size)) self.fullscreen.position = (5, self.widthEdit.height + 15) self.useShaders.position = (5, self.fullscreen.position.y + self.fullscreen.height + 5) self.scroll = ScrollArea(engine.defaultSkin.scrollStyle, self.paramNode) self.scroll.position = (self.formBg.position.x + 257, self.formBg.position.y + 149) self.scroll.geometry = (426 + deltaX, 439 + deltaY) self.addWidget(self.scroll) # RadioButton example #self.group = OpenSR.Engine.RadioButtonGroup() #self.r1 = OpenSR.Engine.RadioButton(engine.defaultSkin().radioButtonStyle, "Yes") #self.r2 = OpenSR.Engine.RadioButton(engine.defaultSkin().radioButtonStyle, "No") #self.r3 = OpenSR.Engine.RadioButton(engine.defaultSkin().radioButtonStyle, "I dunno lol") #self.r2.setPosition(0, self.r1.height + 5) #self.r3.setPosition(0, self.r2.position.y + self.r2.height + 5) #self.group.addRadioButton(self.r1) #self.group.addRadioButton(self.r2) #self.group.addRadioButton(self.r3) #self.group.setPosition(0, 300) #self.paramNode.addWidget(self.group) self.loadSettings() def loadSettings(self): self.widthEdit.text = str( engine.propertiesGetInt("graphics.width", 1024)) self.heightEdit.text = str( engine.propertiesGetInt("graphics.height", 768)) self.fullscreen.checked = engine.propertiesGetBool( "graphics.fullscreen", False) self.useShaders.checked = engine.propertiesGetBool( "graphics.useShaders", True) def saveSettings(self): width = int(self.widthEdit.text) height = int(self.heightEdit.text) fs = self.fullscreen.checked shader = self.useShaders.checked engine.propertiesSetInt("graphics.width", width) engine.propertiesSetInt("graphics.height", height) engine.propertiesSetBool("graphics.fullscreen", fs) engine.propertiesSetBool("graphics.useShaders", shader) def dispose(self): engine.removeWidget(self) self.cancelButton.removeListener(self) self.okButton.removeListener(self) def actionPerformed(self, action): if action.type != Action.Type.BUTTON_CLICKED: return if action.source == self.okButton: self.saveSettings() self.dispose() engine.addWidget(OpenSR.ORC.StartMenu.StartMenuWidget()) def setSoundsDefault(self, button): clickSound = sound.loadSound("Sound/ButtonClick.wav") leaveSound = sound.loadSound("Sound/ButtonLeave.WAV") enterSound = sound.loadSound("Sound/ButtonEnter.wav") button.sounds = (clickSound, leaveSound, enterSound)
class StartMenuWidget(ScriptWidget, ActionListener): BG_SPEED = 20.0 / 1000.0 BUTTON_FILES = { 'newGame': '2ButNew', 'loadGame': '2ButLoad', 'settings': '2ButSettings', 'records': '2ButRecords', 'about': '2ButAbout', 'exit': '2ButExit' } BUTTONS = ['newGame', 'loadGame', 'settings', 'records', 'about', 'exit'] BUTTON_SPARSE = 60 def __init__(self): ScriptWidget.__init__(self) ActionListener.__init__(self) self.t = 0 self.bgforward = False self.background = Sprite('DATA/FormMain3/2bg.gi') self.background.width = self.background.width / ( engine.screenHeight / self.background.height) self.background.height = engine.screenHeight self.background.layer = -3 self.addChild(self.background) self.bgPlanet = Sprite('DATA/FormMain3/2Planet.gi') self.bgPlanet.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_BOTTOM) self.bgPlanet.position = (0, engine.screenHeight) self.bgPlanet.layer = -2 self.addChild(self.bgPlanet) self.bgAnimLine = GAISprite("DATA/FormMain2/2AnimLine.gai") self.bgAnimLine.origin = (SpriteXOrigin.POSITION_X_RIGHT, SpriteYOrigin.POSITION_Y_TOP) self.bgAnimLine.position = (engine.screenWidth, 0) self.bgAnimLine.layer = 0 self.addChild(self.bgAnimLine) self.bgAnim = GAISprite("DATA/FormMain2/2AnimMain.gai") self.bgAnim.layer = -1 self.bgAnim.height = self.bgAnim.height * engine.screenWidth / self.bgAnim.width self.bgAnim.width = engine.screenWidth self.bgAnim.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_BOTTOM) self.bgAnim.position = (0, engine.screenHeight) self.addChild(self.bgAnim) self.caption = Sprite("DATA/FormMain3/2caption.gi") self.caption.origin = (SpriteXOrigin.POSITION_X_RIGHT, SpriteYOrigin.POSITION_Y_CENTER) self.caption.position = (engine.screenWidth, 110) self.caption.layer = 1 self.addChild(self.caption) self.ship = [None, None, None] self.ship[0] = GAISprite('DATA/FormMain3/2Ship1.gai') self.ship[0].position = (0, engine.screenHeight - self.ship[0].height) self.ship[0].layer = 1 self.ship[0].speed = 1.5 self.ship[0].singleShot = True self.ship[1] = GAISprite('DATA/FormMain3/2Ship2.gai') self.ship[1].position = (0, engine.screenHeight - self.ship[1].height) self.ship[1].layer = 1 self.ship[1].speed = 1.5 self.ship[1].singleShot = True self.ship[1].stop() self.ship[2] = GAISprite('DATA/FormMain3/2Ship3.gai') self.ship[2].position = (0, engine.screenHeight - self.ship[2].height) self.ship[2].layer = 1 self.ship[2].speed = 1.5 self.ship[2].singleShot = True self.ship[2].stop() self.addChild(self.ship[0]) self.currentShip = 0 self.menuNode = WidgetNode() self.menuNode.layer = 2 self.menuNode.position = (engine.screenWidth - 400, 300) self.addWidget(self.menuNode) sound.playMusic("Music/SPECIAL/SpaceIsCalling.dat", False) self.buttons = {} clickSound = "Sound/ButtonClick.wav" leaveSound = "Sound/ButtonLeave.WAV" enterSound = "Sound/ButtonEnter.wav" y = 0 for name in self.BUTTONS: button = Button( 'DATA/FormMain2/' + self.BUTTON_FILES[name] + 'N.gi', 'DATA/FormMain2/' + self.BUTTON_FILES[name] + 'A.gi', 'DATA/FormMain2/' + self.BUTTON_FILES[name] + 'D.gi') self.buttons[name] = button button.addListener(self) button.position = (0, y) button.sounds = (clickSound, enterSound, leaveSound) self.menuNode.addWidget(button) y = y + self.BUTTON_SPARSE self.questButton = Button('DATA/FormLoadRobot/2LoadQuestN.gi', 'DATA/FormLoadRobot/2LoadQuestA.gi', 'DATA/FormLoadRobot/2LoadQuestN.gi') self.questButton.addListener(self) self.questButton.position = (305, engine.screenHeight - 135) self.questButton.layer = 2 self.questButton.sounds = (clickSound, enterSound, leaveSound) self.addWidget(self.questButton) self.pause = False def processLogic(self, dt): if self.pause: return ScriptWidget.processLogic(self, dt) if math.fabs( self.t * self.BG_SPEED) >= self.background.width - engine.screenWidth: self.t = 0 self.bgforward = not self.bgforward if self.bgforward: self.background.position = (-self.t * self.BG_SPEED, 0) else: self.background.position = (-self.background.width + engine.screenWidth + self.t * self.BG_SPEED, 0) if not self.ship[self.currentShip].started: self.removeChild(self.ship[self.currentShip]) self.currentShip = (self.currentShip + 1) % 3 self.addChild(self.ship[self.currentShip]) self.ship[self.currentShip].reset() self.ship[self.currentShip].start() self.t = self.t + dt def dispose(self): engine.removeWidget(self) for name in self.BUTTONS: self.buttons[name].removeListener(self) self.questButton.removeListener(self) def openGame(self): widget = SystemWidget(world.systemManager().currentSystem) engine.addWidget(widget) self.dispose() def startQuest(self, questFile): widget = QuestWidget(questFile) engine.addWidget(widget) self.dispose() def actionPerformed(self, action): if action.type == Action.Type.BUTTON_CLICKED: if action.source == self.buttons['exit']: self.dispose() engine.quit(0) elif action.source == self.buttons['settings']: self.dispose() engine.addWidget(OpenSR.ORC.Settings.SettingsWidget()) elif action.source == self.buttons['newGame']: world.addGenHook(WorldGen()) world.generateWorld() world.saveWorld('test.srw') self.openGame() elif action.source == self.buttons['loadGame']: world.loadWorld('test.srw') self.openGame() elif action.source == self.questButton: self.pause = True self.questDialog = OpenSR.ORC.QuestSelectionWidget.QuestSelectionWidget( ) self.questDialog.layer = 4 self.questDialog.position = (int( (engine.screenWidth - self.questDialog.width) / 2), int( (engine.screenHeight - self.questDialog.height) / 2)) self.questDialog.addListener(self) engine.addWidget(self.questDialog) if action.type == Action.Type.DIALOG_ACCEPT: if action.source == self.questDialog: self.pause = False self.questDialog.dispose() self.questDialog.removeListener(self) engine.removeWidget(self.questDialog) quest = self.questDialog.selectedQuest del self.questDialog self.startQuest(quest) elif action.type == Action.Type.DIALOG_CANCEL: if action.source == self.questDialog: self.pause = False self.questDialog.dispose() self.questDialog.removeListener(self) engine.removeWidget(self.questDialog) del self.questDialog
def __init__(self): ScriptWidget.__init__(self) ActionListener.__init__(self) self.t = 0 self.bgforward = False self.background = Sprite('DATA/FormMain3/2bg.gi') self.background.width = self.background.width / ( engine.screenHeight / self.background.height) self.background.height = engine.screenHeight self.background.layer = -3 self.addChild(self.background) self.bgPlanet = Sprite('DATA/FormMain3/2Planet.gi') self.bgPlanet.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_BOTTOM) self.bgPlanet.position = (0, engine.screenHeight) self.bgPlanet.layer = -2 self.addChild(self.bgPlanet) self.bgAnimLine = GAISprite("DATA/FormMain2/2AnimLine.gai") self.bgAnimLine.origin = (SpriteXOrigin.POSITION_X_RIGHT, SpriteYOrigin.POSITION_Y_TOP) self.bgAnimLine.position = (engine.screenWidth, 0) self.bgAnimLine.layer = 0 self.addChild(self.bgAnimLine) self.bgAnim = GAISprite("DATA/FormMain2/2AnimMain.gai") self.bgAnim.layer = -1 self.bgAnim.height = self.bgAnim.height * engine.screenWidth / self.bgAnim.width self.bgAnim.width = engine.screenWidth self.bgAnim.origin = (SpriteXOrigin.POSITION_X_LEFT, SpriteYOrigin.POSITION_Y_BOTTOM) self.bgAnim.position = (0, engine.screenHeight) self.addChild(self.bgAnim) self.caption = Sprite("DATA/FormMain3/2caption.gi") self.caption.origin = (SpriteXOrigin.POSITION_X_RIGHT, SpriteYOrigin.POSITION_Y_CENTER) self.caption.position = (engine.screenWidth, 110) self.caption.layer = 1 self.addChild(self.caption) self.ship = [None, None, None] self.ship[0] = GAISprite('DATA/FormMain3/2Ship1.gai') self.ship[0].position = (0, engine.screenHeight - self.ship[0].height) self.ship[0].layer = 1 self.ship[0].speed = 1.5 self.ship[0].singleShot = True self.ship[1] = GAISprite('DATA/FormMain3/2Ship2.gai') self.ship[1].position = (0, engine.screenHeight - self.ship[1].height) self.ship[1].layer = 1 self.ship[1].speed = 1.5 self.ship[1].singleShot = True self.ship[1].stop() self.ship[2] = GAISprite('DATA/FormMain3/2Ship3.gai') self.ship[2].position = (0, engine.screenHeight - self.ship[2].height) self.ship[2].layer = 1 self.ship[2].speed = 1.5 self.ship[2].singleShot = True self.ship[2].stop() self.addChild(self.ship[0]) self.currentShip = 0 self.menuNode = WidgetNode() self.menuNode.layer = 2 self.menuNode.position = (engine.screenWidth - 400, 300) self.addWidget(self.menuNode) sound.playMusic("Music/SPECIAL/SpaceIsCalling.dat", False) self.buttons = {} clickSound = "Sound/ButtonClick.wav" leaveSound = "Sound/ButtonLeave.WAV" enterSound = "Sound/ButtonEnter.wav" y = 0 for name in self.BUTTONS: button = Button( 'DATA/FormMain2/' + self.BUTTON_FILES[name] + 'N.gi', 'DATA/FormMain2/' + self.BUTTON_FILES[name] + 'A.gi', 'DATA/FormMain2/' + self.BUTTON_FILES[name] + 'D.gi') self.buttons[name] = button button.addListener(self) button.position = (0, y) button.sounds = (clickSound, enterSound, leaveSound) self.menuNode.addWidget(button) y = y + self.BUTTON_SPARSE self.questButton = Button('DATA/FormLoadRobot/2LoadQuestN.gi', 'DATA/FormLoadRobot/2LoadQuestA.gi', 'DATA/FormLoadRobot/2LoadQuestN.gi') self.questButton.addListener(self) self.questButton.position = (305, engine.screenHeight - 135) self.questButton.layer = 2 self.questButton.sounds = (clickSound, enterSound, leaveSound) self.addWidget(self.questButton) self.pause = False
class QuestWidget(ScriptWidget, ActionListener): def __init__(self, questID): ScriptWidget.__init__(self) ActionListener.__init__(self) self.bg = Sprite("DATA/FormPQuest2/2BG.gi") self.addChild(self.bg) self.paramWindow = NinePatch("ORC/quest_param_win.9.json") self.paramWindow.position = (643, 457) self.paramWindow.geometry = (320, 280) self.addChild(self.paramWindow) self.exitButton = Button("DATA/FormPQuest2/2CloseN.gi", "DATA/FormPQuest2/2CloseA.gi", "DATA/FormPQuest2/2CloseD.gi") self.exitButton.position = (953, 725) self.addWidget(self.exitButton) self.exitButton.addListener(self) self.image = None self.questID = questID self.questFile = resources.datRoot( )['PlanetQuest']['PlanetQuest'][questID].value.replace('\\', '/') player.loadQuest(self.questFile) self.loadImages() self.style = resources.objectManager().getResourceObject( '/world/skin/quest/grey') self.interact = InteractionWidget(Rect(15, 45, 15 + 539, 45 + 363), Rect(15, 482, 15 + 539, 482 + 215), self.style) self.interact.position = (35, 5) self.interact.layer = -2 self.addWidget(self.interact) self.interact.addListener(self) self.paramLabel = ColorLabel("") self.paramLabel.wordWrap = True self.paramLabel.position = (665, 480) self.paramLabel.setFixedSize(280, 280) self.paramLabel.textColor = self.style.color self.paramLabel.selectionColor = self.style.activeColor self.addChild(self.paramLabel) self.skin1Button = Button("DATA/FormPQuest2/2Skin1N.gi", "DATA/FormPQuest2/2Skin1A.gi", "DATA/FormPQuest2/2Skin1D.gi") self.skin1Button.position = (529, 742) self.addWidget(self.skin1Button) self.skin1Button.addListener(self) self.skin2Button = Button("DATA/FormPQuest2/2Skin2N.gi", "DATA/FormPQuest2/2Skin2A.gi", "DATA/FormPQuest2/2Skin2D.gi") self.skin2Button.position = (547, 742) self.addWidget(self.skin2Button) self.skin2Button.addListener(self) self.skin3Button = Button("DATA/FormPQuest2/2Skin3N.gi", "DATA/FormPQuest2/2Skin3A.gi", "DATA/FormPQuest2/2Skin3D.gi") self.skin3Button.position = (565, 742) self.addWidget(self.skin3Button) self.skin3Button.addListener(self) self.skin4Button = Button("DATA/FormPQuest2/2Skin4N.gi", "DATA/FormPQuest2/2Skin4A.gi", "DATA/FormPQuest2/2Skin4D.gi") self.skin4Button.position = (583, 742) self.addWidget(self.skin4Button) self.skin4Button.addListener(self) self.updateWidget() def updateStyle(self): oldInteract = self.interact self.interact = InteractionWidget(Rect(15, 45, 15 + 539, 45 + 363), Rect(15, 482, 15 + 539, 482 + 215), self.style) self.interact.position = (35, 5) self.interact.layer = -2 self.addWidget(self.interact) self.interact.addListener(self) self.updateWidget() if oldInteract: oldInteract.removeListener(self) self.removeWidget(oldInteract) def updateWidget(self): self.selectionsID = [] text = player.currentText.replace("\r\n", "\n") if player.questCompleted: text = text + "\n\n\\c008000" + _( "Quest completed!", "Planet.NotCivil.QuestPlay.MsgSuccess") + "\\cR" elif player.questFailed: text = text + "\n\n\\c800000" + _( "Quest failed!", "Planet.NotCivil.QuestPlay.MsgFail") + "\\cR" if player.death: text = text + "\n\n\\c800000" + _( "You're dead!", "Planet.NotCivil.QuestPlay.MsgDeath") + "\\cR" self.interact.text = text trans = player.visibleTransitions selections = [] for t in trans: self.selectionsID.append(t[0]) selections.append((t[1], t[2])) self.interact.selections = selections self.paramLabel.text = "\n".join(player.visibleParameters) newImage = getCacheDATPath(self.images[player.currentImage]) if newImage != "": if self.image: self.removeChild(self.image) self.image = Sprite(newImage) self.image.layer = -1 self.image.position = (656, 32) self.addChild(self.image) def loadImages(self): self.locImages = {} self.transImages = {} self.images = [] pqi = resources.datRoot()['Data']['PQI'] for r in pqi: v = r.name.split(',') if v[0] != self.questID: continue img = r.value imgID = len(self.images) self.images.append(img) if v[1] == "P" or v[1] == "PAR": for i in v[2:]: self.transImages[int(i)] = imgID else: for i in v[2:]: self.locImages[int(i)] = imgID player.setImages(self.locImages, self.transImages) def dispose(self): engine.removeWidget(self) self.skin1Button.removeListener(self) self.skin2Button.removeListener(self) self.skin3Button.removeListener(self) self.skin4Button.removeListener(self) self.interact.removeListener(self) self.exitButton.removeListener(self) def actionPerformed(self, action): if action.type >= Action.Type.USER and action.source == self.interact: index = action.type - Action.Type.USER player.transit(self.selectionsID[index]) self.updateWidget() if action.type == Action.Type.BUTTON_CLICKED: if action.source == self.exitButton: self.dispose() engine.addWidget(OpenSR.ORC.StartMenu.StartMenuWidget()) if action.source == self.skin1Button: self.style = resources.objectManager().getResourceObject( '/world/skin/quest/grey') self.updateStyle() if action.source == self.skin2Button: self.style = resources.objectManager().getResourceObject( '/world/skin/quest/dark') self.updateStyle() if action.source == self.skin3Button: self.style = resources.objectManager().getResourceObject( '/world/skin/quest/light') self.updateStyle() if action.source == self.skin4Button: self.style = resources.objectManager().getResourceObject( '/world/skin/quest/green') self.updateStyle()