コード例 #1
0
ファイル: spqr_events.py プロジェクト: alej0varas/spqr
def showCity(handle, xpos, ypos):
	"""Display city information screen"""
	city = SDATA.data.map.regions["latium_et_campania"].city

	window = SWINDOW.CWindow(-1, -1, 300, 200, "City Info", True)
	window.modal = True
	# we need a label for the name
	lbl_name = SWIDGET.buildLabel(city.name, SPQR.FONT_VERA_LG)
	lbl_name.rect.x = 20
	lbl_name.rect.y = 20
	# a picture of city and surrounding area
	picture = pygame.Surface((80, 80))
	picture.blit(SGFX.gui.image("buffer"), (0, 0))
	city_image = SWIDGET.buildUniqueImage(picture)
	city_image.rect.x = 20
	city_image.rect.y = 60
	# labels for data:
	lbl_population = SWIDGET.buildLabel("Population", SPQR.FONT_VERA)
	lbl_happiness = SWIDGET.buildLabel("Happiness", SPQR.FONT_VERA)
	lbl_food = SWIDGET.buildLabel("Food consumption", SPQR.FONT_VERA)
	
	btn_ok = SWIDGET.CButton(50, 150, "OK")
	btn_ok.callbacks.mouse_lclk = killModalWindow
	btn_ok.active = True
	window.addWidget(lbl_name)
	window.addWidget(city_image)
	window.addWidget(btn_ok)
	SGFX.gui.addWindow(window)
	SGFX.gui.pauseFlashing()
	# setup dirty rect stuff
	SGFX.gui.addDirtyRect(window.drawWindow(), window.rect)
	return True
コード例 #2
0
ファイル: spqr_events.py プロジェクト: QMickael/SPQR
def showCity(handle, xpos, ypos):
    """Display city information screen"""
    city = SDATA.data.map.regions["sardegna"].city
    print str(city)

    w = SGFX.gui.iWidth('startup')
    h = SGFX.gui.iHeight('startup')
    window = SWINDOW.CWindow(-1, -1, w, h, "City Info", True)
    window.modal = True
    # we need a label for the name
    lbl_name = SWIDGET.buildLabel(city.name, SPQR.FONT_VERA_LG)
    lbl_name.rect.x = w / 2 - 25
    lbl_name.rect.y = 20
    # a picture of city and surrounding area
    picture = pygame.Surface((100, 100))
    picture.blit(SGFX.gui.image("buffer"), (0, 0))
    city_image = SWIDGET.buildUniqueImage(picture)
    city_image.rect.x = 30
    city_image.rect.y = 50

    # labels for data:
    lbl_population = SWIDGET.buildLabel("Population: ")
    lbl_population.rect.x = 150
    lbl_population.rect.y = 50

    lbl_population_data = SWIDGET.buildLabel(str(city))
    lbl_population_data.rect.x = 200
    lbl_population_data.rect.y = 50

    lbl_happiness = SWIDGET.buildLabel("Happiness: ")
    lbl_happiness.rect.x = 150
    lbl_happiness.rect.y = 80

    lbl_food = SWIDGET.buildLabel("Food consumption: ")
    lbl_food.rect.x = 150
    lbl_food.rect.y = 110

    btn_ok = SWIDGET.CButton(w / 2, h - 50, "OK")
    btn_ok.callbacks.mouse_lclk = killModalWindow
    btn_ok.active = True

    widgets = [
        lbl_name, city_image, lbl_population, lbl_happiness, lbl_food, btn_ok
    ]

    for i in widgets:
        window.addWidget(i)

    SGFX.gui.addWindow(window)
    SGFX.gui.unitFlashAndOff()
    # setup dirty rect stuff
    SGFX.gui.addDirtyRect(window.drawWindow(), window.rect)
    return True
コード例 #3
0
ファイル: spqr_events.py プロジェクト: QMickael/SPQR
def widgetTest(handle, xpos, ypos):
    """Routine to bring up a window with all widgets
	   on display. Used to test widgets, as the name implies"""
    # we start by building up all of the widgets
    lbl_widget = SWIDGET.buildLabel("Label")
    lbl_widget.rect.x = 10
    lbl_widget.rect.y = 10
    btn_widget = SWIDGET.CButton(10, 30, "Quit")
    btn_widget.callbacks.mouse_lclk = killModalWindow
    btn_widget.active = True
    chk_widget = SWIDGET.CCheckBox(10, 68, True)
    chk_widget.active = True
    sld_widget = SWIDGET.CSlider(10, 90, 150, 0, 150, 75)
    sld_widget.active = True
    dc_widget = SWIDGET.buildLabel("Double-Click Me!")
    dc_widget.rect.x = 20
    dc_widget.rect.y = 230
    dc_widget.active = True
    dc_widget.callbacks.mouse_dclick = dclickTest
    options = ["Romans", "Iberians", "Greeks", "Selucids"]
    opt_widget = SWIDGET.COptionMenu(120, 30, options)
    opt_widget.active = True
    w = SGFX.gui.iWidth("test_image")
    scl_widget = SWIDGET.CScrollArea(10, 114, w, 96,
                                     SGFX.gui.image("test_image"))
    scl_widget.active = True
    # make sure we have a console output for the example slider
    sld_widget.setUpdateFunction(displaySliderContents)
    # let's have a window
    index = SGFX.gui.addWindow(
        SWINDOW.CWindow(-1, -1, 260, 300, "Widget Test", True))
    # add items to window
    SGFX.gui.windows[index].addWidget(lbl_widget)
    SGFX.gui.windows[index].addWidget(btn_widget)
    SGFX.gui.windows[index].addWidget(chk_widget)
    SGFX.gui.windows[index].addWidget(sld_widget)
    SGFX.gui.windows[index].addWidget(scl_widget)
    SGFX.gui.windows[index].addWidget(dc_widget)
    SGFX.gui.windows[index].addWidget(opt_widget)

    # set it modal
    SGFX.gui.windows[index].modal = True
    # there is only one key, but don't forget to add an enter one button windows
    SGFX.gui.keyboard.addKey(K_q, killModalWindow)
    SGFX.gui.keyboard.addKey(K_RETURN, killModalWindow)
    SGFX.gui.keyboard.setModalKeys(2)
    # turn off unit animations for the moment and thats it
    SGFX.gui.unitFlashAndOff()
    # add the dirty rect details
    SGFX.gui.addDirtyRect(SGFX.gui.windows[index].drawWindow(),
                          SGFX.gui.windows[index].rect)
    return True
コード例 #4
0
ファイル: spqr_events.py プロジェクト: maximinus/SPQR
def menuPreferences(handle, xpos, ypos):
	"""Display the user preferences window. You can only really
	   play with the music and volume settings for now"""
	# first off, let's make the window that we need
	index = SGFX.gui.addWindow(SWINDOW.CWindow(-1, -1, 288, 152, "SPQR Preferences", True))
	# we'll need an image first
	img = SWIDGET.buildImageAlpha("img_music")
	img.rect.x = 20
	img.rect.y = 20
	# a couple of labels, and there positions
	lbl_MusicOn = SWIDGET.buildLabel("Music On:")
	lbl_MusicOn.rect.x = 88
	lbl_MusicOn.rect.y = 28
	lbl_Volume = SWIDGET.buildLabel("Volume:")
	lbl_Volume.rect.x = 88
	lbl_Volume.rect.y = 60
	# a checkbox for the music option
	chk_Volume = SWIDGET.CCheckBox(247, 30, SSFX.sound.music_playing)
	chk_Volume.active = True
	# connect it to some code
	chk_Volume.addAfterClick(musicCheckbox)
	# a slider for the volume
	sld_Volume = SWIDGET.CSlider(160, 62, 100, 0, 100, SSFX.sound.getVolume())
	sld_Volume.active = True
	# connect to some code
	sld_Volume.setUpdateFunction(setVolume)
	# a seperator
	sep = SWIDGET.CSeperator(10, 90, 274 - SPQR.WINSZ_SIDE)
	# and an ok button
	btn_ok = SWIDGET.CButton(190, 106, "OK")
	btn_ok.callbacks.mouse_lclk = killModalWindow
	btn_ok.active = True
	# add them all to our window
	SGFX.gui.windows[index].addWidget(img)
	SGFX.gui.windows[index].addWidget(lbl_MusicOn)
	SGFX.gui.windows[index].addWidget(lbl_Volume)
	SGFX.gui.windows[index].addWidget(chk_Volume)
	SGFX.gui.windows[index].addWidget(sld_Volume)
	SGFX.gui.windows[index].addWidget(sep)
	SGFX.gui.windows[index].addWidget(btn_ok)
	# make the window modal
	SGFX.gui.windows[index].modal = True
	# add the new key event: o = ok
	SGFX.gui.keyboard.addKey(K_o, killModalWindow)
	SGFX.gui.keyboard.setModalKeys(1)
	# turn off unit animations
	SGFX.gui.unitFlashAndOff()
	# setup dirty rect stuff
	SGFX.gui.addDirtyRect(SGFX.gui.windows[index].drawWindow(),
		SGFX.gui.windows[index].rect)
	# and thats us done
	return True
コード例 #5
0
ファイル: spqr_events.py プロジェクト: maximinus/SPQR
def widgetTest(handle, xpos, ypos):
	"""Routine to bring up a window with all widgets
	   on display. Used to test widgets, as the name implies"""
	# we start by building up all of the widgets
	lbl_widget = SWIDGET.buildLabel("Label")
	lbl_widget.rect.x = 10
	lbl_widget.rect.y = 10
	btn_widget = SWIDGET.CButton(10, 30, "Quit")
	btn_widget.callbacks.mouse_lclk = killModalWindow
	btn_widget.active = True	
	chk_widget = SWIDGET.CCheckBox(10, 68, True)
	chk_widget.active = True
	sld_widget = SWIDGET.CSlider(10, 90, 150, 0, 150, 75)
	sld_widget.active = True
	dc_widget = SWIDGET.buildLabel("Double-Click Me!")
	dc_widget.rect.x = 20
	dc_widget.rect.y = 230
	dc_widget.active = True
	dc_widget.callbacks.mouse_dclick = dclickTest
	options = ["Romans", "Iberians", "Greeks", "Selucids"]
	opt_widget = SWIDGET.COptionMenu(120, 30, options)
	opt_widget.active = True
	w = SGFX.gui.iWidth("test_image")
	scl_widget = SWIDGET.CScrollArea(10, 114, w, 96, SGFX.gui.image("test_image"))
	scl_widget.active = True
	# make sure we have a console output for the example slider
	sld_widget.setUpdateFunction(displaySliderContents)
	# let's have a window
	index = SGFX.gui.addWindow(SWINDOW.CWindow(-1, -1, 260, 300, "Widget Test", True))
	# add items to window
	SGFX.gui.windows[index].addWidget(lbl_widget)
	SGFX.gui.windows[index].addWidget(btn_widget)
	SGFX.gui.windows[index].addWidget(chk_widget)
	SGFX.gui.windows[index].addWidget(sld_widget)
	SGFX.gui.windows[index].addWidget(scl_widget)
	SGFX.gui.windows[index].addWidget(dc_widget)
	SGFX.gui.windows[index].addWidget(opt_widget)
	
	# set it modal
	SGFX.gui.windows[index].modal = True
	# there is only one key, but don't forget to add an enter one button windows
	SGFX.gui.keyboard.addKey(K_q, killModalWindow)
	SGFX.gui.keyboard.addKey(K_RETURN, killModalWindow)
	SGFX.gui.keyboard.setModalKeys(2)
	# turn off unit animations for the moment and thats it
	SGFX.gui.unitFlashAndOff()
	# add the dirty rect details
	SGFX.gui.addDirtyRect(SGFX.gui.windows[index].drawWindow(),
		SGFX.gui.windows[index].rect)
	return True
コード例 #6
0
ファイル: spqr_ybuild.py プロジェクト: QMickael/SPQR
def createWidget(wlist):
    """ Function that creates a widget and returns it based on the
		passed list of properties """
    # First we check the key that will always be in our widget's
    # and defines the widget's purpose
    if wlist['widget'] == "CLabel":
        # if this is a label make it with a text
        label = SWIDGET.buildLabel(wlist['text'])
        # and add the cords to the rect
        label.rect.x = wlist['x']
        label.rect.y = wlist['y']
        # Check if there is any widgets
        try:
            checkCallbacks(label, wlist['callbacks'])
        except:
            pass
        return label
    elif wlist['widget'] == "CCheckBox":
        intro = SWIDGET.CCheckBox(wlist['x'], wlist['y'], wlist['initial'])
        return intro
    elif wlist['widget'] == "COptionMenu":
        options = SWIDGET.COptionMenu(wlist['x'], wlist['y'], wlist['options'])
        options.describe = wlist['describe']
        return options
    elif wlist['widget'] == "CSeperator":
        sepbar = SWIDGET.CSeperator(wlist['x'], wlist['y'], wlist['w'])
        return sepbar
    elif wlist['widget'] == "CSlider":
        sepbar = SWIDGET.CSlider(wlist['x'], wlist['y'], wlist['w'],
                                 wlist['start'], wlist['stop'],
                                 wlist['initial'])
        return sepbar
    elif wlist['widget'] == "CButton":
        # if it is a button we create it and then we must put the callbacks in
        button = SWIDGET.CButton(wlist['x'], wlist['y'], wlist['text'])
        # for every callback we check the given function from the global list
        checkCallbacks(button, wlist['callbacks'])
        return button
    elif wlist['widget'] == "CScrollArea":
        image = SGFX.gui.image(wlist['image'])
        sepbar = SWIDGET.CScrollArea(wlist['x'], wlist['y'], wlist['w'],
                                     wlist['h'], image)
        sepbar.setUpdateFunction(getattr(SEVENTS, wlist['update']))
        return sepbar
    elif wlist['widget'] == "CButtonDetails":
        buttondetail = SWINDOW.CButtonDetails(
            wlist['text'], wlist['key'], getattr(SEVENTS, wlist["callback"]))
        return buttondetail
コード例 #7
0
ファイル: spqr_ybuild.py プロジェクト: maximinus/SPQR
def createWidget(wlist):
	""" Function that creates a widget and returns it based on the
		passed list of properties """
	# First we check the key that will always be in our widget's
	# and defines the widget's purpose
	if wlist['widget'] == "CLabel" :
		# if this is a label make it with a text
		label = SWIDGET.buildLabel(wlist['text'])
		# and add the cords to the rect
		label.rect.x = wlist['x']
		label.rect.y = wlist['y']
		# Check if there is any widgets
		try:
			checkCallbacks(label,wlist['callbacks'])
		except:
			pass
		return label
	elif wlist['widget'] == "CCheckBox" :
		intro = SWIDGET.CCheckBox(wlist['x'], wlist['y'], wlist['initial'])
		return intro
	elif wlist['widget'] == "COptionMenu" :
		options = SWIDGET.COptionMenu(wlist['x'], wlist['y'], wlist['options'])
		options.describe = wlist['describe']
		return options
	elif wlist['widget'] == "CSeperator" :
		sepbar = SWIDGET.CSeperator(wlist['x'] , wlist['y'], wlist['w'])
		return sepbar
	elif wlist['widget'] == "CSlider" :
		sepbar = SWIDGET.CSlider(wlist['x'] , wlist['y'], wlist['w'],wlist['start'] , wlist['stop'], wlist['initial'])
		return sepbar
	elif wlist['widget'] == "CButton" :
		# if it is a button we create it and then we must put the callbacks in
		button = SWIDGET.CButton(wlist['x'] , wlist['y'] , wlist['text'])
		# for every callback we check the given function from the global list
		checkCallbacks(button,wlist['callbacks'])
		return button
	elif wlist['widget'] == "CScrollArea" :
		image=SGFX.gui.image(wlist['image'])
		sepbar = SWIDGET.CScrollArea(wlist['x'] , wlist['y'] , wlist['w'] , wlist['h'] , image)
		sepbar.setUpdateFunction(getattr(SEVENTS, wlist['update']))
		return sepbar
	elif wlist['widget'] == "CButtonDetails" :
		buttondetail = SWINDOW.CButtonDetails(wlist['text'], wlist['key'], getattr(SEVENTS, wlist["callback"]))
		return buttondetail
コード例 #8
0
ファイル: spqr_events.py プロジェクト: QMickael/SPQR
def factionOptionScreen(handle, xpos, ypos):
    """Screen to choose the starting faction for the player"""
    #kill the welcomeScreen
    killModalWindow(0, 0, 0)
    # set the sizes
    w = 700
    h = 420
    # build the window1
    window_factions = SWINDOW.CWindow(-1, -1, w, h, 'Factions playable', True)

    # list faction playable
    lbl_gauls = SWIDGET.buildLabel('Gauls')
    lbl_gauls.rect.x = 70
    lbl_gauls.rect.y = 20
    logo_gauls = SWIDGET.CImage(40, 40, 110, 130, 'logo_gauls')

    lbl_germans = SWIDGET.buildLabel('Germans')
    lbl_germans.rect.x = 200
    lbl_germans.rect.y = 20
    logo_germans = SWIDGET.CImage(180, 40, 110, 130, 'logo_germans')

    lbl_egypt = SWIDGET.buildLabel('Egypt')
    lbl_egypt.rect.x = 350
    lbl_egypt.rect.y = 20
    logo_egypt = SWIDGET.CImage(320, 40, 110, 130, 'logo_egypt')

    lbl_greeks = SWIDGET.buildLabel('Greeks')
    lbl_greeks.rect.x = 70
    lbl_greeks.rect.y = 180
    logo_greeks = SWIDGET.CImage(40, 200, 110, 130, 'logo_greeks')

    lbl_carthage = SWIDGET.buildLabel('Carthage')
    lbl_carthage.rect.x = 200
    lbl_carthage.rect.y = 180
    logo_carthage = SWIDGET.CImage(180, 200, 110, 130, 'logo_carthage')

    lbl_rome = SWIDGET.buildLabel('Rome')
    lbl_rome.rect.x = 350
    lbl_rome.rect.y = 180
    logo_rome = SWIDGET.CImage(320, 200, 110, 130, 'logo_rome')

    # faction option
    lbl_options_faction = SWIDGET.buildLabel('Faction choose: ')
    lbl_options_faction.rect.x = 500
    lbl_options_faction.rect.y = 20
    options_faction = SWIDGET.COptionMenu(
        500, 40, ['Gauls', 'Germans', 'Egypt', 'Greeks', 'Carthage', 'Rome'])
    options_faction.describe = "opt-faction"

    # AI Difficulty option
    lbl_ai = SWIDGET.buildLabel('AI Difficulty: ')
    lbl_ai.rect.x = 500
    lbl_ai.rect.y = 90
    options_ai = SWIDGET.COptionMenu(500, 110, ['Easy', 'Medium', 'Hard'])
    options_ai.describe = "opt-IA"

    # army option
    lbl_army = SWIDGET.buildLabel('Army: ')
    lbl_army.rect.x = 500
    lbl_army.rect.y = 160
    options_army = SWIDGET.COptionMenu(
        500, 180, ['60 soldiers', '120 soldiers', '200 soldiers'])
    options_army.describe = "opt-Army"

    # a separator
    sep = SWIDGET.CSeperator(130, 350, 350)

    # create the 2 main buttons
    btn_play = SWIDGET.CButton(300, 370, "Play")
    btn_previous = SWIDGET.CButton(205, 370, "Previous")

    # add callbacks
    btn_play.callbacks.mouse_lclk = startGame
    btn_previous.callbacks.mouse_lclk = welcomeScreen
    #btn_previous.callbacks.mouse_lclk = killModalWindow

    # widgets list
    widgets = [
        btn_play, btn_previous, sep, lbl_ai, options_ai, lbl_gauls, logo_gauls,
        lbl_germans, logo_germans, lbl_egypt, logo_egypt, lbl_greeks,
        logo_greeks, lbl_carthage, logo_carthage, lbl_rome, logo_rome,
        lbl_options_faction, options_faction, lbl_army, options_army
    ]

    # add all that to the window
    for i in widgets:
        i.active = True
        window_factions.addWidget(i)
    # make modal
    window_factions.modal = True

    # turn off unit animations
    SGFX.gui.unitFlashAndOff()
    # add the window as a dirty image
    SGFX.gui.addDirtyRect(window_factions.drawWindow(), window_factions.rect)
    SGFX.gui.addWindow(window_factions)
    return True
コード例 #9
0
ファイル: spqr_events.py プロジェクト: QMickael/SPQR
def menuEmpireCouncil(handle, xpos, ypos):
    """Temp routine, just displays a messagebox for now"""
    #string = "It is not possible to visit the senate at this moment in time."
    #SGFX.gui.messagebox(SPQR.BUTTON_OK, string, "Visit Senate")
    w = SGFX.gui.iWidth("startup")
    h = SGFX.gui.iHeight("startup") * 1.5
    window = SWINDOW.CWindow(-1, -1, w, h, "Visit Council", True)
    window.modal = True

    ## image spqr
    spqr_img = SWIDGET.buildImage('logo_rome')
    spqr_img.rect.x = SGFX.gui.iWidth('logo_rome') / 2
    spqr_img.rect.y = 20

    ## separators from the top and the bottom
    sep_top = SWIDGET.CSeperator(w / 10, h / 3, w / 1.2)
    sep_bottom = SWIDGET.CSeperator(w / 3, h - 70, w / 3)

    ## statics from your empire
    lbl_population = SWIDGET.buildLabel('Population: ')
    lbl_population.rect.x = 190
    lbl_population.rect.y = 30

    lbl_happiness = SWIDGET.buildLabel('Happiness: ')
    lbl_happiness.rect.x = 190
    lbl_happiness.rect.y = 60

    lbl_regions = SWIDGET.buildLabel('Regions: ')
    lbl_regions.rect.x = 190
    lbl_regions.rect.y = 90

    lbl_food = SWIDGET.buildLabel('Food: ')
    lbl_food.rect.x = 190
    lbl_food.rect.y = 120

    lbl_naval_armies = SWIDGET.buildLabel('Naval Armies: ')
    lbl_naval_armies.rect.x = 370
    lbl_naval_armies.rect.y = 30

    lbl_armies = SWIDGET.buildLabel('Armies: ')
    lbl_armies.rect.x = 370
    lbl_armies.rect.y = 60

    lbl_faction_at_war = SWIDGET.buildLabel('At war with: ')
    lbl_faction_at_war.rect.x = 370
    lbl_faction_at_war.rect.y = 90

    lbl_faction_allies = SWIDGET.buildLabel('Allies: ')
    lbl_faction_allies.rect.x = 370
    lbl_faction_allies.rect.y = 120

    string = SWIDGET.buildLabel(
        "It is not possible to visit the council at this moment in time.")
    string.rect.x = 50
    string.rect.y = 250

    ## ok button
    btn_ok = SWIDGET.CButton(w / 2.2, h - 50, "OK")
    btn_ok.callbacks.mouse_lclk = killModalWindow
    btn_ok.active = True

    ## add widgets to window
    widgets = [
        spqr_img, btn_ok, sep_top, sep_bottom, lbl_population, lbl_happiness,
        lbl_food, lbl_armies, lbl_naval_armies, lbl_faction_at_war,
        lbl_faction_allies, lbl_regions, string
    ]

    for i in widgets:
        window.addWidget(i)

    SGFX.gui.addWindow(window)
    SGFX.gui.unitFlashAndOff()
    # setup dirty rect stuff
    SGFX.gui.addDirtyRect(window.drawWindow(), window.rect)
    return True
コード例 #10
0
ファイル: spqr_events.py プロジェクト: QMickael/SPQR
def menuPreferences(handle, xpos, ypos):
    """Display the user preferences window. You can only really
	   play with the music and volume settings for now"""
    # first off, let's make the window that we need
    index = SGFX.gui.addWindow(
        SWINDOW.CWindow(-1, -1, 328, 252, "SPQR Preferences", True))
    # we'll need an image first
    img = SWIDGET.buildImageAlpha("img_music")
    img.rect.x = 20
    img.rect.y = 20
    ## now image for display monitor
    img_display = SWIDGET.buildImageAlpha('display')
    img_display.rect.x = 20
    img_display.rect.y = 90
    # a couple of labels, and there positions
    lbl_MusicOn = SWIDGET.buildLabel("Music On:")
    lbl_MusicOn.rect.x = 88
    lbl_MusicOn.rect.y = 28
    lbl_Volume = SWIDGET.buildLabel("Volume:")
    lbl_Volume.rect.x = 88
    lbl_Volume.rect.y = 60
    ## new label for screen settings
    lbl_screenResolution = SWIDGET.buildLabel('Resolution:')
    lbl_screenResolution.rect.x = 88
    lbl_screenResolution.rect.y = 100
    ## option for display monitor
    options_display = SWIDGET.COptionMenu(
        178, 95, ['Fullscreen', '1024x768', '800x600'])
    options_display.describe = "opt-Resolution"
    options_display.active = True
    # a checkbox for the music option
    chk_Volume = SWIDGET.CCheckBox(180, 30, SSFX.sound.music_playing)
    chk_Volume.active = True
    # connect it to some code
    chk_Volume.addAfterClick(musicCheckbox)
    # a slider for the volume
    sld_Volume = SWIDGET.CSlider(180, 62, 140, 0, 100, SSFX.sound.getVolume())
    sld_Volume.active = True
    # connect to some code
    sld_Volume.setUpdateFunction(setVolume)
    # a seperator
    sep = SWIDGET.CSeperator(10, 190, 300 - SPQR.WINSZ_SIDE)
    ## an apply button
    btn_apply = SWIDGET.CButton(120, 215, 'Apply')
    btn_apply.callbacks.mouse_lclk = resizeWindow
    btn_apply.active = True
    # and an ok button
    btn_ok = SWIDGET.CButton(210, 215, "OK")
    btn_ok.callbacks.mouse_lclk = killModalWindow
    btn_ok.active = True
    # add them all to our window
    SGFX.gui.windows[index].addWidget(img)
    SGFX.gui.windows[index].addWidget(lbl_MusicOn)
    ## add news settings
    SGFX.gui.windows[index].addWidget(img_display)
    SGFX.gui.windows[index].addWidget(lbl_screenResolution)
    SGFX.gui.windows[index].addWidget(options_display)
    SGFX.gui.windows[index].addWidget(lbl_Volume)
    SGFX.gui.windows[index].addWidget(chk_Volume)
    SGFX.gui.windows[index].addWidget(sld_Volume)
    SGFX.gui.windows[index].addWidget(sep)
    SGFX.gui.windows[index].addWidget(btn_apply)
    SGFX.gui.windows[index].addWidget(btn_ok)
    # make the window modal
    SGFX.gui.windows[index].modal = True
    # add the new key event: o = ok
    SGFX.gui.keyboard.addKey(K_o, killModalWindow)
    SGFX.gui.keyboard.setModalKeys(1)
    # turn off unit animations
    SGFX.gui.unitFlashAndOff()
    # setup dirty rect stuff
    SGFX.gui.addDirtyRect(SGFX.gui.windows[index].drawWindow(),
                          SGFX.gui.windows[index].rect)
    # and thats us done
    return True
コード例 #11
0
ファイル: spqr_battle.py プロジェクト: alej0varas/spqr
	def __init__(self, attacker, region):
		self.result = None
		# get the defending units (only the first for now)
		# must be some units, we checked earlier
		defender = region.units[0]
		region = region
		# now we have all we need to build the base window
		window = SWINDOW.CWindow(-1, -1, 390, 300, "Battle Screen", False)
		window.modal = True
		ystart = SGFX.gui.iHeight("win_tl")
		# we need widgets for the unit names
		attack_unit_label = SWIDGET.buildLabel(str(attacker), SPQR.FONT_VERA_BOLD)
		attack_unit_label.rect.x = int((180 - attack_unit_label.rect.width) / 2) + 10
		attack_unit_label.rect.y = 60 + ystart
		defend_unit_label = SWIDGET.buildLabel(str(defender), SPQR.FONT_VERA_BOLD)
		defend_unit_label.rect.x = int((180 - defend_unit_label.rect.width) / 2) + 200
		defend_unit_label.rect.y = 60 + ystart
		# pictures of the units
		attack_image = SWIDGET.buildImageAlpha(attacker.image)
		attack_image.rect.x = int((180 - SPQR.UNIT_WIDTH) / 2) + 10
		attack_image.rect.y = 15 + ystart
		defend_image = SWIDGET.buildImageAlpha(defender.image)
		defend_image.rect.x = int((180 - SPQR.UNIT_WIDTH) / 2) + 200
		defend_image.rect.y = 15 + ystart
		for widget in [attack_unit_label, defend_unit_label, attack_image,	defend_image]:
			window.addWidget(widget)
		# get the random elements and add them
		xpos = 20
		ypos1 = 85 + ystart
		for event in self.getAttackEvents():
			label = SWIDGET.buildLabel(event)
			label.rect.x = xpos
			label.rect.y = ypos1
			window.addWidget(label)
			ypos1 += 20
		xpos = 220
		ypos2 = 85 + ystart
		for event in self.getDefendEvents():
			label = SWIDGET.buildLabel(event)
			label.rect.x = xpos
			label.rect.y = ypos2
			window.addWidget(label)
			ypos2 += 20
		# how far?
		if ypos2 > ypos1:
			ypos1 = ypos2
		ypos1 += 12
		# build in the options
		attack_text = SWIDGET.buildLabel("Attack style:", SPQR.FONT_VERA_ITALIC)
		attack_text.rect.x = 20
		attack_text.rect.y = ypos1
		defend_text = SWIDGET.buildLabel("Retreat:", SPQR.FONT_VERA_ITALIC)
		defend_text.rect.x = 220
		defend_text.rect.y = ypos1
		window.addWidget(attack_text)
		window.addWidget(defend_text)
		ypos1 += 20
		opt1 = SWIDGET.COptionMenu(20, ypos1, attack_options)
		opt2 = SWIDGET.COptionMenu(220, ypos1, retreat_options)
		opt1.active = True
		opt2.active = True
		window.addWidget(opt1)
		window.addWidget(opt2)
		ypos1 += 40
		window.addWidget(SWIDGET.CSeperator(10, ypos1, 370))
		ypos1 += 15
		# add withdraw and attack buttons
		btn_attack = SWIDGET.CButton(297, ypos1, "Attack")
		btn_attack.callbacks.mouse_lclk = self.doBattle
		btn_attack.active = True
		btn_withdraw = SWIDGET.CButton(200, ypos1, "Withdraw")
		btn_withdraw.callbacks.mouse_lclk = self.retreatBattle
		btn_withdraw.active = True
		window.addWidget(btn_attack)
		window.addWidget(btn_withdraw)
		window.rect.height = ypos1 + 50
		window.renderWindowBackdrop()
		SGFX.gui.addWindow(window)
		SGFX.gui.pauseFlashing()
		# setup dirty rect stuff
		SGFX.gui.addDirtyRect(window.drawWindow(), window.rect)
コード例 #12
0
ファイル: spqr_ybuild.py プロジェクト: alej0varas/spqr
def createWidget(wlist):
	""" Function that creates a widget and returns it based on the
		passed list of properties """
	# First we check the key that will always be in our widget's
	# and defines the widget's purpose
	if wlist['widget'] == "CText":
		height = SGFX.gui.fonts[eval(wlist['font'])].get_height() * eval(wlist['lines'])
		width = SGFX.gui.fonts[eval(wlist['font'])].size('X')[0] * eval(wlist['chars'])
		widget = SWIDGET.CText(eval(wlist['x']), eval(wlist['y']), width, height, eval(wlist['lines']), eval(wlist['font']))
		# check if there are any widgets callback
		if wlist.has_key('callbacks'):
			checkCallbacks(widget, wlist['callbacks'])
		if wlist['active'] == True:
			widget.active = True
		else: 
			widget.active = False
		if wlist['visible'] == True:
			widget.visible = True
		else:
			widget.visible = False
		return widget
	elif wlist['widget'] == "CLabel":
		# if this is a label make it with a text
		widget = SWIDGET.buildLabel(wlist['text'])
		# and add the cords to the rect
		widget.rect.x = eval(wlist['x'])
		widget.rect.y = eval(wlist['y'])
		# Check if there is any widgets callback
		if wlist.has_key('callbacks'):
			checkCallbacks(widget,wlist['callbacks'])
		if wlist['active'] == True:
			widget.active = True
		else:
			widget.active = False
		if wlist['visible'] == True:
			widget.visible = True
		else:
			widget.visible = False
		return widget
	elif wlist['widget'] == "CCheckBox":
		widget = SWIDGET.CCheckBox(eval(wlist['x']) , eval(wlist['y']) , eval(wlist['initial']))
		if wlist.has_key('after'):
			widget.addAfterClick(getattr(SEVENTS, wlist['after']))
		if wlist['active'] == True:
			widget.active = True
		else:
			widget.active = False
		if wlist['visible'] == True:
			widget.visible = True
		else:
			widget.visible = False
		return widget
	elif wlist['widget'] == "COptionMenu":
		widget = SWIDGET.COptionMenu(eval(wlist['x']), eval(wlist['y']) , wlist['options'])
		widget.describe = wlist['describe']
		if wlist['active'] == True:
			widget.active = True
		else:
			widget.active = False
		if wlist['visible'] == True:
			widget.visible = True
		else:
			widget.visible = False
		return widget
	elif wlist['widget'] == "CSeperator" :
		widget = SWIDGET.CSeperator(eval(wlist['x']) , eval(wlist['y']) , eval(wlist['w']))
		if wlist['active'] == True:
			widget.active = True
		else:
			widget.active = False
		if wlist['visible'] == True:
			widget.visible = True
		else:
			widget.visible = False
		return widget
	elif wlist['widget'] == "CSlider" :
		widget = SWIDGET.CSlider(eval(wlist['x']), eval(wlist['y']), eval(wlist['w']), 
		  						 eval(wlist['start']), eval(wlist['stop']), eval(wlist['initial']))
		widget.setUpdateFunction(getattr(SEVENTS, wlist['update']))
		if wlist['active'] == True:
			widget.active = True
		else:
			widget.active = False
		if wlist['visible'] == True:
			widget.visible = True
		else:
			widget.visible = False
		return widget
	elif wlist['widget'] == "CButton":
		# if it is a button we create it and then we must put the callbacks in
		widget = SWIDGET.CButton(eval(wlist['x']), eval(wlist['y']), wlist['text'])
		# for every callback we check the given function from the global list
		checkCallbacks(widget,wlist['callbacks'])
		if wlist['active'] == True:
			widget.active = True
		else:
			widget.active = False
		if wlist['visible'] == True:
			widget.visible = True
		else:
			widget.visible = False
		return widget
	elif wlist['widget'] == "CScrollArea":
		image = SGFX.gui.image(wlist['image'])
		widget = SWIDGET.CScrollArea(eval(wlist['x']), eval(wlist['y']), eval(wlist['w']),
									 eval(wlist['h']) , image)
		if wlist['active'] == True:
			widget.active = True
		else:
			widget.active = False
		if wlist['visible'] == True:
			widget.visible = True
		else:
			widget.visible = False
		return widget
	elif wlist['widget'] == "CButtonDetails" :
		widget = SWINDOW.CButtonDetails(wlist['text'], wlist['key'], getattr(SEVENTS, wlist["callback"]))
		if wlist['active'] == True:
			widget.active = True
		else:
			widget.active = False
		if wlist['visible'] == True:
			widget.visible = True
		else:
			widget.visible = False
		return widget
	elif wlist['widget'] == "CImage" :
		if wlist['alpha'] == 1:
			widget = SWIDGET.buildImageAlpha(wlist['image'])
		else:
			widget = SWIDGET.buildImage(wlist['image'])
		widget.rect.x = eval(wlist['x'])
		widget.rect.y = eval(wlist['y'])
		if wlist.has_key('callbacks'):
			checkCallbacks(widget,wlist['callbacks'])
		if wlist['active'] == True:
			widget.active = True
		else:
			widget.active = False
		if wlist['visible'] == True:
			widget.visible = True
		else:
			widget.visible = False
		return widget
	elif wlist['widget'] == "CBlankButton" :
		widget = SWIDGET.CButton(eval(wlist['x']), eval(wlist['y']), "*BLANK*")
		widget.rect.width = eval(wlist['w'])
		widget.rect.height = eval(wlist['h'])
		checkCallbacks(widget, wlist['callbacks'])
		if wlist['active'] == True:
			widget.active = True
		else:
			widget.active = False
		if wlist['visible'] == True:
			widget.visible = True
		else:
			widget.visible = False
		return widget