예제 #1
0
def refresh_buttons():
    global play_buttons
    global delete_buttons

    for i in range(global_data.max_presets):

        delete_buttons[i] = 0
        if preset_controller.presets[i] != 0:

            play_buttons[i] = buttons.StandardButton(
                renderer.mid_x, renderer.mid_y + i * 50 - 200,
                typing.retro_8x10, preset_controller.presets[i].name)
            delete_buttons[i] = buttons.StandardButton(
                renderer.mid_x + 300, renderer.mid_y + i * 50 - 200,
                typing.retro_8x10, 'delete')

        else:

            play_buttons[i] = buttons.StandardButton(
                renderer.mid_x, renderer.mid_y + i * 50 - 200,
                typing.retro_8x10, no_preset_message)
#	run - runs the main menu
#
# ================================================================================================
"""
                                         Joseph Coppin
                                  Computer Science GSCE Coursework

Description of file

Global Functions:

Imports:                                                                                         """
center_x = renderer.mid_x
center_y = renderer.mid_y

main_menu_button = buttons.StandardButton(center_x, center_y - 100,
                                          typing.retro_8x10, 'main menu')
enter_airport_details = buttons.StandardButton(center_x, center_y + 150,
                                               typing.retro_8x10,
                                               'enter airport details')
enter_flight_details = buttons.StandardButton(center_x, center_y + 200,
                                              typing.retro_8x10,
                                              'enter flight details')


# ================================================================================================
#  run -- runs and controls the menu option
#
#  INPUT:  none
#
#  RETURNS:  int - dependant on what options have been selected
#
예제 #3
0
Global Functions:
    run
    tick_stats

Imports:                                                                                         """
import program_listing.full.buttons as buttons
import program_listing.full.global_data as global_data
import program_listing.full.typing as typing
import program_listing.full.clear_data as clear_data
import program_listing.full.renderer as renderer

center_x = renderer.mid_x
center_y = renderer.mid_y

quit_button = buttons.StandardButton(120, 30, typing.retro_8x10, 'quit')
clear_data_button = buttons.StandardButton(renderer.screen_x - 120, 30,
                                           typing.retro_8x10, 'clear')

save_to_preset = buttons.StandardButton(center_x - 100, center_y - 150,
                                        typing.retro_8x10, 'save')
load_preset = buttons.StandardButton(center_x + 100, center_y - 150,
                                     typing.retro_8x10, 'load')

calculate_profits_button = buttons.StandardButton(center_x, center_y - 100,
                                                  typing.retro_8x10,
                                                  'calculate profits')

enter_airport_details = buttons.StandardButton(center_x, center_y + 150,
                                               typing.retro_8x10,
                                               'enter airport details')
예제 #4
0
def price_checker(price):
    try:
        price = int(price)
        if 10000 > price > 0:
            return True
    except:
        pass

    return False


first_price_box = buttons.TextBoxWithCheck(renderer.mid_x, renderer.mid_y, typing.retro_8x10, '', 4, price_checker)
standard_price_box = buttons.TextBoxWithCheck(renderer.mid_x, renderer.mid_y + 100, typing.retro_8x10, '', 4, price_checker)

next_button = buttons.StandardButton(renderer.mid_x, renderer.mid_y + 200, typing.retro_8x10, 'next')


def find_overseas_airport():
    for i in global_data.list_of_airports:
        if i.code == global_data.overseas_airport:
            return i


def run_normal_menu():
    first_price_box.run()
    standard_price_box.run()

    typing.write(typing.retro_8x10, 'Price of a first class ticket:', (renderer.mid_x, renderer.mid_y - 50))
    typing.write(typing.retro_8x10, 'Price of a standard class ticket:', (renderer.mid_x, renderer.mid_y + 50))
예제 #5
0
# ------------------------------------------------------------------------------------------------
#
#	run - runs this menu option
#
# ================================================================================================
"""
                                         Joseph Coppin
                                  Computer Science GSCE Coursework

Description of file

Global Functions:

Imports:                                                                                         """

main_menu_button = buttons.StandardButton(renderer.mid_x, renderer.mid_y + 200,
                                          typing.retro_8x10, 'main menu')


# ================================================================================================
#  run -- runs and controls the menu option
#
#  INPUT:  none
#
#  RETURNS:  none
#
#  CREATED: 28/07/2020
# ================================================================================================
def run():
    typing.write(typing.retro_8x10, 'Route stats:',
                 (renderer.mid_x, renderer.mid_y - 175))
예제 #6
0
Controls the save page for saving the current as a preset

Global Functions:
    preset_name_check
    run

Imports:                                                                                         """
import program_listing.full.global_data as global_data
import program_listing.full.renderer as renderer
import program_listing.full.buttons as buttons
import program_listing.full.typing as typing
import program_listing.full.preset_controller as preset_controller


back_button = buttons.StandardButton(renderer.mid_x, renderer.mid_y - 100,
                                     typing.retro_8x10, 'back')
save_button = buttons.StandardButton(renderer.mid_x, renderer.mid_y,
                                     typing.retro_8x10,
                                     'save current as preset')


def preset_name_check(message):
    if len(message) > 0:
        for i in range(global_data.max_presets):
            if preset_controller.presets[i] != 0:
                if message == preset_controller.presets[i].name:
                    return False
        return True
    return False

    if global_data.airplane_type > 0:
        airplane_data = global_data.airplane_types_data[global_data.airplane_type]

        if number > airplane_data[global_data.min_first_class]:
            if number < airplane_data[global_data.max_capacity] / 2:
                return True

    return False


mid_x = renderer.mid_x
mid_y = renderer.mid_y

first_seats_box = buttons.TextBoxWithCheck(mid_x, mid_y + 50, typing.retro_8x10, '', 3, first_seats_checker)

medium_narrow_button = buttons.StandardButton(mid_x, mid_y - 150, typing.retro_8x10, 'Medium narrow')
large_narrow_button = buttons.StandardButton(mid_x, mid_y - 100, typing.retro_8x10, 'Large narrow')
medium_wide_button = buttons.StandardButton(mid_x, mid_y - 50, typing.retro_8x10, 'Medium wide')

get_info_button = buttons.StandardButton(mid_x, mid_y - 250, typing.retro_8x10, 'get info')

save_button = buttons.StandardButton(mid_x, mid_y + 200, typing.retro_8x10, 'save and exit')


# ================================================================================================
#  run -- runs and controls the menu option
#
#  INPUT:  none
#
#  RETURNS:  none
#
예제 #8
0
# ------------------------------------------------------------------------------------------------
#
#	run - runs this menu option
#
# ================================================================================================
"""
                                         Joseph Coppin
                                  Computer Science GSCE Coursework

Description of file

Global Functions:

Imports:                                                                                         """

back_button = buttons.StandardButton(renderer.mid_x, renderer.mid_y + 250,
                                     typing.retro_8x10, 'back')


# ================================================================================================
#  run -- runs and controls the menu option
#
#  INPUT:  none
#
#  RETURNS:  none
#
#  CREATED: 28/07/2020
# ================================================================================================
def run():
    info = global_data.airplane_types_data[global_data.airplane_type]

    message = 'running cost: ' + str(info[global_data.running_cost])
        if str.lower(airport.code) == message.lower():
            found = True

    if found:
        return True
    return False


overseas_airport_box = buttons.TextBoxWithCheck(mid_x, mid_y + 50,
                                                typing.retro_8x10, '', 3,
                                                overseas_airport_checker)

uk_airport_box = buttons.TextBoxWithCheck(mid_x, mid_y - 50, typing.retro_8x10,
                                          '', 3, uk_airport_checker)

save_button = buttons.StandardButton(mid_x, mid_y + 100, typing.retro_8x10,
                                     'save and exit')


# ================================================================================================
#  run -- runs and controls the menu option
#
#  INPUT:  none
#
#  RETURNS:  none
#
#  CREATED: 28/07/2020
# ================================================================================================
def run():
    typing.write(typing.retro_8x10, 'UK airport:',
                 (renderer.mid_x, renderer.mid_y - 100))
    typing.write(typing.retro_8x10, 'Overseas airport:',
예제 #10
0
Controls the menu option to load a preset

Global Functions:
    refresh_buttons
    run

Imports:                                                                                         """
import program_listing.full.global_data as global_data
import program_listing.full.renderer as renderer
import program_listing.full.buttons as buttons
import program_listing.full.typing as typing
import program_listing.full.preset_controller as preset_controller

play_buttons = {}
delete_buttons = {}
back_button = buttons.StandardButton(110, 30, typing.retro_8x10, 'back')

no_preset_message = 'no preset'


# ================================================================================================
#  refresh_buttons -- runs and controls the menu option
#
#  INPUT:  none
#
#  RETURNS:  none
#
#  CREATED: 28/07/2020
# ================================================================================================
def refresh_buttons():
    global play_buttons