Пример #1
0
MenuVendor::MenuVendor(SDL_Surface *_screen, InputState *_inp, FontEngine *_font, ItemDatabase *_items, StatBlock *_stats, MessageEngine *_msg) {
	screen = _screen;
	inp = _inp;
	font = _font;
	items = _items;
	stats = _stats;
	msg = _msg;

	int offset_y = (VIEW_H - 416)/2;

	slots_area.x = 32;
	slots_area.y = offset_y + 64;
	slots_area.w = 256;
	slots_area.h = 320;

	stock.init( VENDOR_SLOTS, items, screen, font, slots_area, ICON_SIZE_32, 8);

	visible = false;
	loadGraphics();

	closeButton = new WidgetButton(screen, font, inp, "images/menus/buttons/button_x.png");
	closeButton->pos.x = 294;
	closeButton->pos.y = (VIEW_H - 480)/2 + 34;

	loadMerchant("");
}
Пример #2
0
MenuInventory::MenuInventory(SDL_Surface *_screen, FontEngine *_font, ItemDatabase *_items, StatBlock *_stats, PowerManager *_powers) {
	screen = _screen;
	font = _font;
	items = _items;
	stats = _stats;
	powers = _powers;
	
	visible = false;
	loadGraphics();

	window_area.w = 320;
	window_area.h = 416;
	window_area.x = VIEW_W - window_area.w;
	window_area.y = (VIEW_H - window_area.h)/2;

	equipped_area.x = window_area.x + 32;
	equipped_area.y = window_area.y + 48;
	equipped_area.w = 256;
	equipped_area.h = 64;
	
	carried_area.x = window_area.x + 32;
	carried_area.y = window_area.y + 128;
	carried_area.w = 256;
	carried_area.h = 256;

	inventory[EQUIPMENT].init(MAX_EQUIPPED, items, screen, font, equipped_area, ICON_SIZE_64, 4);
	inventory[CARRIED].init(MAX_CARRIED, items, screen, font, carried_area, ICON_SIZE_32, 8);
	
	gold = 0;
	
	drag_prev_src = -1;
	changed_equipment = true;
	changed_artifact = true;
}
Пример #3
0
/**
 * Powers can cause new enemies to spawn
 * Check PowerManager for any new queued enemies
 */
void EnemyManager::handleSpawn() {
	
	EnemySpawn espawn;
	
	while (!powers->enemies.empty()) {
		espawn = powers->enemies.front();		
		powers->enemies.pop();	

		enemies[enemy_count] = new Enemy(powers, map);
		enemies[enemy_count]->stats.pos.x = espawn.pos.x;
		enemies[enemy_count]->stats.pos.y = espawn.pos.y;
		enemies[enemy_count]->stats.direction = espawn.direction;
		enemies[enemy_count]->stats.load("enemies/" + espawn.type + ".txt");
		if (enemies[enemy_count]->stats.animations != "") {
			// load the animation file if specified
			enemies[enemy_count]->loadAnimations("animations/" + enemies[enemy_count]->stats.animations + ".txt");
		}
		else {
			cout << "Warning: no animation file specified for entity: " << espawn.type << endl;
		}
		loadGraphics(enemies[enemy_count]->stats.gfx_prefix);
		loadSounds(enemies[enemy_count]->stats.sfx_prefix);
		
		// special animation state for spawning enemies
		enemies[enemy_count]->stats.cur_state = ENEMY_SPAWN;
		enemy_count++;	
	}
}
Пример #4
0
LootManager::LootManager()
	: tip(new WidgetTooltip())
	, sfx_loot(snd->load(eset->loot.sfx_loot, "LootManager dropping loot"))
{
	loadGraphics();
	loadLootTables();
}
Пример #5
0
MenuEnemy::MenuEnemy(SDL_Surface *_screen, FontEngine *_font) {
	screen = _screen;
	font = _font;
	loadGraphics();
	enemy = NULL;
	timeout = 0;
}
Пример #6
0
MenuActiveEffects::MenuActiveEffects(StatBlock *_stats)
	: timer(NULL)
	, stats(_stats)
	, orientation(false) { // horizontal
	// Load config settings
	FileParser infile;
	// @CLASS MenuActiveEffects|Description of menus/activeeffects.txt
	if(infile.open("menus/activeeffects.txt")) {
		while(infile.next()) {
			if (parseMenuKey(infile.key, infile.val))
				continue;

			// @ATTR orientation|bool|True is vertical orientation; False is horizontal orientation.
			if(infile.key == "orientation") {
				orientation = toBool(infile.val);
			}
			else {
				infile.error("MenuActiveEffects: '%s' is not a valid key.", infile.key.c_str());
			}
		}
		infile.close();
	}

	loadGraphics();
	align();
}
Пример #7
0
LootManager::LootManager()
	: sfx_loot(0)
	, drop_max(1)
	, drop_radius(1)
	, hero(NULL)
	, tooltip_margin(0)
{
	tip = new WidgetTooltip();

	FileParser infile;
	// load loot animation settings from engine config file
	// @CLASS Loot|Description of engine/loot.txt
	if (infile.open("engine/loot.txt")) {
		while (infile.next()) {
			if (infile.key == "tooltip_margin") {
				// @ATTR tooltip_margin|integer|Vertical offset of the loot tooltip from the loot itself.
				tooltip_margin = toInt(infile.val);
			}
			else if (infile.key == "autopickup_currency") {
				// @ATTR autopickup_currency|boolean|Enable autopickup for currency
				AUTOPICKUP_CURRENCY = toBool(infile.val);
			}
			else if (infile.key == "currency_name") {
				// This key is parsed in loadMiscSettings() in Settings.cpp
			}
			else if (infile.key == "vendor_ratio") {
				// @ATTR vendor_ratio|integer|Prices ratio for vendors
				VENDOR_RATIO = static_cast<float>(toInt(infile.val)) / 100.0f;
			}
			else if (infile.key == "sfx_loot") {
				// @ATTR sfx_loot|string|Filename of a sound effect to play for dropping loot.
				sfx_loot =  snd->load(infile.val, "LootManager dropping loot");
			}
			else if (infile.key == "drop_max") {
				// @ATTR drop_max|integer|The maximum number of random item stacks that can drop at once
				drop_max = toInt(infile.val);
				clampFloor(drop_max, 1);
			}
			else if (infile.key == "drop_radius") {
				// @ATTR drop_radius|integer|The distance (in tiles) away from the origin that loot can drop
				drop_radius = toInt(infile.val);
				clampFloor(drop_radius, 1);
			}
			else {
				infile.error("LootManager: '%s' is not a valid key.", infile.key.c_str());
			}
		}
		infile.close();
	}

	// reset current map loot
	loot.clear();

	loadGraphics();

	full_msg = false;

	loadLootTables();
}
Пример #8
0
void CTester::load() {

	gEnv->pRenderer->addRenderPass("tester", VK_ATTACHMENT_LOAD_OP_LOAD);

	gEnv->pRenderer->addGraphicsPipeline(gEnv->pRenderer->getShader("color"), gEnv->pRenderer->getRenderPass("tester"), "tester", false);
	loadGraphics();
	updateUniformBuffer();
}
Пример #9
0
MenuEnemy::MenuEnemy(SDL_Surface *_screen, FontEngine *_font, MessageEngine *_msg) {
	screen = _screen;
	font = _font;
	msg = _msg;
	loadGraphics();
	enemy = NULL;
	timeout = 0;
}
Пример #10
0
MenuCharacter::MenuCharacter(SDL_Surface *_screen, FontEngine *_font, StatBlock *_stats) {
	screen = _screen;
	font = _font;
	stats = _stats;
	
	visible = false;

	loadGraphics();
}
Пример #11
0
void ScalpelInventory::putInv(InvSlamMode slamIt) {
	ScalpelScreen &screen = *(ScalpelScreen *)_vm->_screen;
	UserInterface &ui = *_vm->_ui;

	// If an inventory item has disappeared (due to using it or giving it),
	// a blank space slot may have appeared. If so, adjust the inventory
	if (_invIndex > 0 && _invIndex > (_holdings - (int)_invShapes.size())) {
		--_invIndex;
		freeGraphics();
		loadGraphics();
	}

	if (slamIt != SLAM_SECONDARY_BUFFER) {
		screen.makePanel(Common::Rect(6, 163, 54, 197));
		screen.makePanel(Common::Rect(58, 163, 106, 197));
		screen.makePanel(Common::Rect(110, 163, 158, 197));
		screen.makePanel(Common::Rect(162, 163, 210, 197));
		screen.makePanel(Common::Rect(214, 163, 262, 197));
		screen.makePanel(Common::Rect(266, 163, 314, 197));
	}

	// Iterate through displaying up to 6 objects at a time
	for (int idx = _invIndex; idx < _holdings && (idx - _invIndex) < (int)_invShapes.size(); ++idx) {
		int itemNum = idx - _invIndex;
		Surface &bb = slamIt == SLAM_SECONDARY_BUFFER ? screen._backBuffer2 : screen._backBuffer1;
		Common::Rect r(8 + itemNum * 52, 165, 51 + itemNum * 52, 194);

		// Draw the background
		if (idx == ui._selector) {
			bb.fillRect(r, BUTTON_BACKGROUND);
		}
		else if (slamIt == SLAM_SECONDARY_BUFFER) {
			bb.fillRect(r, BUTTON_MIDDLE);
		}

		// Draw the item image
		ImageFrame &frame = (*_invShapes[itemNum])[0];
		bb.transBlitFrom(frame, Common::Point(6 + itemNum * 52 + ((47 - frame._width) / 2),
			163 + ((33 - frame._height) / 2)));
	}

	if (slamIt == SLAM_DISPLAY)
		screen.slamArea(6, 163, 308, 34);

	if (slamIt != SLAM_SECONDARY_BUFFER)
		ui.clearInfo();

	if (slamIt == 0) {
		invCommands(0);
	}
	else if (slamIt == SLAM_SECONDARY_BUFFER) {
		screen._backBuffer = &screen._backBuffer2;
		invCommands(0);
		screen._backBuffer = &screen._backBuffer1;
	}
}
Пример #12
0
MenuLog::MenuLog(SDL_Surface *_screen, InputState *_inp, FontEngine *_font) {
	screen = _screen;
	inp = _inp;
	font = _font;

	visible = false;
	
	for (int i=0; i<LOG_TYPE_COUNT; i++) {
		log_count[i] = 0;
	}
	active_log = 0;

	tab_labels[LOG_TYPE_MESSAGES] = msg->get("Messages");
	tab_labels[LOG_TYPE_QUESTS] = msg->get("Quests");
	tab_labels[LOG_TYPE_STATISTICS] = msg->get("Statistics");

	// TODO: allow menu size to be configurable
	menu_area.x = 0;
	menu_area.y = (VIEW_H - 416)/2;
	menu_area.w = 320;
	menu_area.h = 416;
	
	list_area.x = menu_area.x + 40;
	list_area.y = menu_area.y + 56;
	list_area.w = 224;
	list_area.h = 328;
	
	tabs_area.x = menu_area.x + 32;
	tabs_area.y = menu_area.y + 30;
	tabs_area.w = 240;
	tabs_area.h = 20;

	tab_padding.y = 4;
	tab_padding.x = 6;
	paragraph_spacing = 6;
	
	for (int i=0; i<LOG_TYPE_COUNT; i++) {
		tab_rect[i].y = tabs_area.y;
		tab_rect[i].h = tabs_area.h;
		
		if (i==0) tab_rect[i].x = tabs_area.x;
		else tab_rect[i].x = tab_rect[i-1].x + tab_rect[i-1].w;
		
		tab_rect[i].w = font->calc_length(tab_labels[i]) + tab_padding.x + tab_padding.x;
		
	}
	
	loadGraphics();

	closeButton = new WidgetButton(screen, font, inp, "images/menus/buttons/button_x.png");
	closeButton->pos.x = 294;
	closeButton->pos.y = (VIEW_H - 480)/2 + 34;
	
}
Пример #13
0
WidgetTabControl::WidgetTabControl()
	: active_tab_surface(NULL)
	, inactive_tab_surface(NULL)
	, active_tab(0)
	, tab_padding(8,4) {

	loadGraphics();

	color_normal = font->getColor("widget_normal");
	color_disabled = font->getColor("widget_disabled");

	scroll_type = HORIZONTAL;
}
Пример #14
0
GameStateLoad::GameStateLoad(SDL_Surface *_screen, InputState *_inp, FontEngine *_font) : GameState(_screen, _inp, _font) {
	items = new ItemDatabase(screen, font);
	portrait = NULL;
	
	button_exit = new WidgetButton(screen, font, inp, "./images/menus/buttons/button_default.png");
	button_exit->label = "Exit to Title";
	button_exit->pos.x = VIEW_W_HALF - button_exit->pos.w/2;
	button_exit->pos.y = VIEW_H - button_exit->pos.h;	
	
	button_action = new WidgetButton(screen, font, inp, "./images/menus/buttons/button_default.png");
	button_action->label = "Choose a Slot";
	button_action->enabled = false;
	button_action->pos.x = (VIEW_W - 640)/2 + 480 - button_action->pos.w/2;
	button_action->pos.y = (VIEW_H - 480)/2 + 384;
	
	load_game = false;
	
	for (int i=0; i<GAME_SLOT_MAX; i++) {
		sprites[i] = NULL;
		current_map[i] = "";
	}
	
	loadGraphics();
	readGameSlots();
	
	for (int i=0; i<GAME_SLOT_MAX; i++) {
		slot_pos[i].x = (VIEW_W - 640)/2;
		slot_pos[i].y = (VIEW_H - 480)/2 + (i * 96) + 32;
		slot_pos[i].w = 288;
		slot_pos[i].h = 96;
	}
	
	selected_slot = -1;
	
	// label positions within each slot
	name_pos.x = 16;
	name_pos.y = 16;

	level_pos.x = 24;
	level_pos.y = 40;

	map_pos.x = 24;
	map_pos.y = 56;

	sprites_pos.x = 178;
	sprites_pos.y = -24;
	
	// temp
	current_frame = 0;
	frame_ticker = 0;
}
Пример #15
0
MenuActionBar::MenuActionBar(SDL_Surface *_screen, FontEngine *_font, InputState *_inp, PowerManager *_powers, SDL_Surface *_icons) {
	screen = _screen;
	font = _font;
	inp = _inp;
	powers = _powers;
	icons = _icons;
	
	src.x = 0;
	src.y = 0;
	src.w = 32;
	src.h = 32;
	label_src.x = 0;
	label_src.y = 0;
	label_src.w = 640;
	label_src.h = 10;
	drag_prev_slot = -1;
	
	clear();
	
	// TEMP: set action bar positions
	// TODO: define in a config file so that the menu is customizable
	int offset_x = (VIEW_W - 640)/2;
	int offset_y = VIEW_H-32;
	
	for (int i=0; i<12; i++) {
		slots[i].w = slots[i].h = 32;
		slots[i].y = VIEW_H-32;
		slots[i].x = offset_x + i*32 + 32;
	}
	slots[10].x += 32;
	slots[11].x += 32;
	
	// menu button positions
	for (int i=0; i<4; i++) {
		menus[i].w = menus[i].h = 32;
		menus[i].y = VIEW_H-32;
		menus[i].x = offset_x + 480 + i*32;
	}
		
	// screen areas occupied by the three main sections	
	numberArea.h = mouseArea.h = menuArea.h = 32;
	numberArea.y = mouseArea.y = menuArea.y = offset_y;
	numberArea.x = offset_x+32;
	numberArea.w = 320;
	mouseArea.x = offset_x+384;
	mouseArea.w = 64;
	menuArea.x = offset_x+480;
	menuArea.w = 128;
	
	loadGraphics();
}
Пример #16
0
MenuExit::MenuExit(SDL_Surface *_screen, InputState *_inp, FontEngine *_font) : Menu(_screen, inp = _inp, _font) {
	exitClicked = false;

	window_area.w = 192;
	window_area.h = 64;
	window_area.x = (VIEW_W/2) - (window_area.w/2);
	window_area.y = (VIEW_H - window_area.h)/2;
	
	buttonExit = new WidgetButton(screen, font, inp, "./images/menus/buttons/button_default.png");
	buttonExit->label = "Exit";
	buttonExit->pos.x = VIEW_W_HALF - buttonExit->pos.w/2;
	buttonExit->pos.y = VIEW_H/2;

	loadGraphics();
}
Пример #17
0
MenuPowers::MenuPowers(StatBlock *_stats, MenuActionBar *_action_bar)
	: stats(_stats)
	, action_bar(_action_bar)
	, skip_section(false)
	, powers_unlock(NULL)
	, overlay_disabled(NULL)
	, points_left(0)
	, default_background("")
	, tab_control(NULL)
	, tree_loaded(false)
	, prev_powers_list_size(0)
	, newPowerNotification(false)
{

	closeButton = new WidgetButton("images/menus/buttons/button_x.png");

	// Read powers data from config file
	FileParser infile;
	// @CLASS MenuPowers: Menu layout|Description of menus/powers.txt
	if (infile.open("menus/powers.txt")) {
		while (infile.next()) {
			if (parseMenuKey(infile.key, infile.val))
				continue;

			// @ATTR label_title|label|Position of the "Powers" text.
			if (infile.key == "label_title") title = eatLabelInfo(infile.val);
			// @ATTR unspent_points|label|Position of the text that displays the amount of unused power points.
			else if (infile.key == "unspent_points") unspent_points = eatLabelInfo(infile.val);
			// @ATTR close|point|Position of the close button.
			else if (infile.key == "close") close_pos = toPoint(infile.val);
			// @ATTR tab_area|rectangle|Position and dimensions of the tree pages.
			else if (infile.key == "tab_area") tab_area = toRect(infile.val);

			else infile.error("MenuPowers: '%s' is not a valid key.", infile.key.c_str());
		}
		infile.close();
	}

	loadGraphics();

	menu_powers = this;

	color_bonus = font->getColor("menu_bonus");
	color_penalty = font->getColor("menu_penalty");
	color_flavor = font->getColor("item_flavor");

	align();
}
Пример #18
0
WidgetInput::WidgetInput() {
	
	enabled = true;
	inFocus = false;
	pressed = false;
	max_characters = 20;
	
	loadGraphics(mods->locate("images/menus/input.png"));

	// position
	pos.w = background->w;
	pos.h = background->h/2;
	
	cursor_frame = 0;
	
}
Пример #19
0
/**
 * Overloaded function for case, if slot positions are predefined
 */
void MenuItemStorage::init(int _slot_number, std::vector<Rect> _area, std::vector<std::string> _slot_type) {
    ItemStorage::init( _slot_number);
    for (int i = 0; i < _slot_number; i++) {
        WidgetSlot *slot = new WidgetSlot();
        slot->pos = _area[i];
        slot->setBasePos(slot->pos.x, slot->pos.y);
        slots.push_back(slot);
    }
    nb_cols = 0;
    slot_type = _slot_type;
    highlight = new bool[_slot_number];
    for (int i=0; i<_slot_number; i++) {
        highlight[i] = false;
    }
    loadGraphics();
}
Пример #20
0
WidgetInput::WidgetInput(const std::string& filename)
	: background(NULL)
	, enabled(true)
	, pressed(false)
	, hover(false)
	, cursor_pos(0)
	, edit_mode(false)
	, max_length(0)
	, only_numbers(false)
	, accept_to_defocus(true)
{

	loadGraphics(filename);

	render_to_alpha = false;
	color_normal = font->getColor("widget_normal");
}
Пример #21
0
WidgetInput::WidgetInput(SDL_Surface* _screen, FontEngine *_font, InputState *_inp)
	: screen(_screen), font(_font), inp(_inp) {
	
	enabled = true;
	inFocus = false;
	pressed = false;
	max_characters = 20;
	
	loadGraphics("images/menus/input.png");

	// position
	pos.w = background->w;
	pos.h = background->h/2;
	
	cursor_frame = 0;
	
}
Пример #22
0
/**
 * When loading a new map, we eliminate existing enemies and load the new ones.
 * The map will have loaded Entity blocks into an array; retrieve the Enemies and init them
 */
void EnemyManager::handleNewMap () {
	
	Map_Enemy me;
	
	// delete existing enemies
	for (int i=0; i<enemy_count; i++) {
		delete(enemies[i]);
	}
	enemy_count = 0;
	
	// free shared resources
	for (int j=0; j<gfx_count; j++) {
		SDL_FreeSurface(sprites[j]);
	}
	for (int j=0; j<sfx_count; j++) {
		Mix_FreeChunk(sound_phys[j]);
		Mix_FreeChunk(sound_ment[j]);
		Mix_FreeChunk(sound_hit[j]);
		Mix_FreeChunk(sound_die[j]);
		Mix_FreeChunk(sound_critdie[j]);
	}
	gfx_count = 0;
	sfx_count = 0;
	
	// load new enemies
	while (!map->enemies.empty()) {
		me = map->enemies.front();
		map->enemies.pop();
		
		enemies[enemy_count] = new Enemy(powers, map);
		enemies[enemy_count]->stats.pos.x = me.pos.x;
		enemies[enemy_count]->stats.pos.y = me.pos.y;
		enemies[enemy_count]->stats.direction = me.direction;
		enemies[enemy_count]->stats.load("enemies/" + me.type + ".txt");
		if (enemies[enemy_count]->stats.animations != "") {
			// load the animation file if specified
			enemies[enemy_count]->loadAnimations("animations/" + enemies[enemy_count]->stats.animations + ".txt");
		}
		else {
			cout << "Warning: no animation file specified for entity: " << me.type << endl;
		}
		loadGraphics(enemies[enemy_count]->stats.gfx_prefix);
		loadSounds(enemies[enemy_count]->stats.sfx_prefix);
		enemy_count++;
	}
}
Пример #23
0
LootManager::LootManager(ItemDatabase *_items, MenuTooltip *_tip, EnemyManager *_enemies, MapIso *_map) {
	items = _items;
	tip = _tip;
	enemies = _enemies; // we need to be able to read loot state when creatures die
	map = _map; // we need to be able to read loot that drops from map containers
	
	tooltip_margin = 32; // pixels between loot drop center and label
	
	loot_count = 0;
	animation_count = 0;
	
	for (int i=0; i<64; i++) {
		flying_loot[i] = NULL;
		animation_id[i] = "";
	}
	
	loot_flip = NULL;
	
	// reset current map loot
	for (int i=0; i<256; i++) {
		loot[i].pos.x = 0;
		loot[i].pos.y = 0;
		loot[i].frame = 0;
		loot[i].stack.item = 0;
		loot[i].stack.quantity = 0;
		loot[i].gold = 0;
	}

	// reset loot table
	for (int lvl=0; lvl<15; lvl++) {
		loot_table_count[lvl] = 0;
		for (int num=0; num<256; num++) {
			loot_table[lvl][num] = 0;
		}
	}
	
	loadGraphics();
	calcTables();
	loot_flip = Mix_LoadWAV("soundfx/flying_loot.ogg");
	full_msg = false;
	
	anim_loot_frames = 6;
	anim_loot_duration = 3;
	
}
Пример #24
0
MenuVendor::MenuVendor(SDL_Surface *_screen, FontEngine *_font, ItemDatabase *_items, StatBlock *_stats) {
	screen = _screen;
	font = _font;
	items = _items;
	stats = _stats;
	
	int offset_y = (VIEW_H - 416)/2;
	
	slots_area.x = 32;
	slots_area.y = offset_y + 64;
	slots_area.w = 256;
	slots_area.h = 320;
	
	stock.init( VENDOR_SLOTS, items, screen, font, slots_area, ICON_SIZE_32, 8);

	visible = false;
	loadGraphics();
	loadMerchant("");
}
Пример #25
0
void TileSet::load(string filename) {
    if (current_map == filename) return;

    ifstream infile;
    string line;
    unsigned short index;

    infile.open(("tilesetdefs/" + filename).c_str(), ios::in);

    if (infile.is_open()) {
        string img;

        // first line is the tileset image filename
        line = getLine(infile);

        img = line;

        while (!infile.eof()) {
            line = getLine(infile);

            if (line.length() > 0) {
                line = line + ',';

                // split across comma
                // line contains:
                // index, x, y, w, h, ox, oy

                index = eatFirstHex(line, ',');
                tiles[index].src.x = eatFirstInt(line, ',');
                tiles[index].src.y = eatFirstInt(line, ',');
                tiles[index].src.w = eatFirstInt(line, ',');
                tiles[index].src.h = eatFirstInt(line, ',');
                tiles[index].offset.x = eatFirstInt(line, ',');
                tiles[index].offset.y = eatFirstInt(line, ',');
            }
        }

        infile.close();
        loadGraphics(img);
    }

    current_map = filename;
}
Пример #26
0
MenuInventory::MenuInventory(SDL_Surface *_screen, InputState *_inp, FontEngine *_font, ItemDatabase *_items, StatBlock *_stats, PowerManager *_powers, MessageEngine *_msg) {
	screen = _screen;
	inp = _inp;
	font = _font;
	items = _items;
	stats = _stats;
	powers = _powers;
	msg = _msg;
	
	visible = false;
	loadGraphics();

	window_area.w = 320;
	window_area.h = 416;
	window_area.x = VIEW_W - window_area.w;
	window_area.y = (VIEW_H - window_area.h)/2;

	equipped_area.x = window_area.x + 32;
	equipped_area.y = window_area.y + 48;
	equipped_area.w = 256;
	equipped_area.h = 64;
	
	carried_area.x = window_area.x + 32;
	carried_area.y = window_area.y + 128;
	carried_area.w = 256;
	carried_area.h = 256;

	inventory[EQUIPMENT].init(MAX_EQUIPPED, items, screen, font, equipped_area, ICON_SIZE_64, 4);
	inventory[CARRIED].init(MAX_CARRIED, items, screen, font, carried_area, ICON_SIZE_32, 8);
	
	gold = 0;
	
	drag_prev_src = -1;
	changed_equipment = true;
	changed_artifact = true;
	log_msg = "";
	
	closeButton = new WidgetButton(screen, font, inp, "images/menus/buttons/button_x.png");
	closeButton->pos.x = VIEW_W - 26;
	closeButton->pos.y = (VIEW_H - 480)/2 + 34;

}
Пример #27
0
void MenuItemStorage::init(int _slot_number, Rect _area, int _icon_size, int _nb_cols) {
    ItemStorage::init( _slot_number);
    grid_area = _area;
    grid_pos.x = _area.x;
    grid_pos.y = _area.y;
    for (int i = 0; i < _slot_number; i++) {
        WidgetSlot *slot = new WidgetSlot();
        slots.push_back(slot);
    }
    nb_cols = _nb_cols;
    highlight = new bool[_slot_number];
    for (int i=0; i<_slot_number; i++) {
        highlight[i] = false;
        slots[i]->pos.x = grid_area.x + (i % nb_cols * _icon_size);
        slots[i]->pos.y = grid_area.y + (i / nb_cols * _icon_size);
        slots[i]->pos.h = slots[i]->pos.w = _icon_size;
        slots[i]->setBasePos(slots[i]->pos.x, slots[i]->pos.y);
    }
    loadGraphics();
}
Пример #28
0
GameStateTitle::GameStateTitle(SDL_Surface *_screen, InputState *_inp, FontEngine *_font) : GameState(_screen, _inp, _font) {

    exit_game = false;
    load_game = false;

    loadGraphics();

    // set up buttons
    button_play = new WidgetButton(screen, font, inp, "./images/menus/buttons/button_default.png");
    button_exit = new WidgetButton(screen, font, inp, "./images/menus/buttons/button_default.png");

    button_play->label = "Play Game";
    button_play->pos.x = VIEW_W_HALF - button_play->pos.w/2;
    button_play->pos.y = VIEW_H - (button_exit->pos.h*2);

    button_exit->label = "Exit Game";
    button_exit->pos.x = VIEW_W_HALF - button_exit->pos.w/2;
    button_exit->pos.y = VIEW_H - button_exit->pos.h;

}
Пример #29
0
MenuPowers::MenuPowers(SDL_Surface *_screen, FontEngine *_font, StatBlock *_stats, PowerManager *_powers) {
    screen = _screen;
    font = _font;
    stats = _stats;
    powers = _powers;

    visible = false;
    loadGraphics();


    // set slot positions
    int offset_x = (VIEW_W - 320);
    int offset_y = (VIEW_H - 416)/2;

    for (int i=0; i<20; i++) {
        slots[i].w = slots[i].h = 32;
        slots[i].x = offset_x + 48 + (i % 4) * 64;
        slots[i].y = offset_y + 80 + (i / 4) * 64;
    }
}
Пример #30
0
MenuExit::MenuExit() : Menu() {

	exitClicked = false;

	window_area.w = 192;
	window_area.h = 64;
	window_area.x = (VIEW_W/2) - (window_area.w/2);
	window_area.y = (VIEW_H - window_area.h)/2;
	
	buttonExit = new WidgetButton(mods->locate("images/menus/buttons/button_default.png"));
	buttonExit->label = msg->get("Exit");
	buttonExit->pos.x = VIEW_W_HALF - buttonExit->pos.w/2;
	buttonExit->pos.y = VIEW_H/2;

	buttonClose = new WidgetButton(mods->locate("images/menus/buttons/button_x.png"));
	buttonClose->pos.x = window_area.x + window_area.w;
	buttonClose->pos.y = window_area.y;

	loadGraphics();
}