Skip to content
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents 455de1e + 06ecd75 commit 838a78c63b74e68500608565b44f00f8eef49002 @clintbellanger committed Sep 30, 2012
View
4 CMakeLists.txt
@@ -23,9 +23,9 @@ else (CMAKE_CXX_COMPILER MATCHES "clang")
endif (CMAKE_CXX_COMPILER MATCHES "clang")
if(CMAKE_BUILD_TYPE STREQUAL "Release")
- set(CMAKE_CXX_FLAGS_RELEASE "-O2 -g0 -flto")
+ set(CMAKE_CXX_FLAGS_RELEASE "-O2 -g0")
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
- set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -flto")
+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -g0")
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
View
1 mods/default/engine/misc.txt
@@ -3,3 +3,4 @@
#save_hpmp=0
#default_name=
#corpse_timeout=1800
+#sell_without_vendor=1
View
2 src/GameStateConfig.cpp
@@ -1266,7 +1266,7 @@ bool GameStateConfig::setMods() {
*/
void GameStateConfig::scanKey(int button) {
if (input_confirm->visible) {
- if (inpt->last_button != -1) {
+ if (inpt->last_button != -1 && inpt->last_button < 8) {
if (button < 25) inpt->binding[button] = inpt->last_button;
else inpt->binding_alt[button-25] = inpt->last_button;
View
106 src/GameStateLoad.cpp
@@ -29,8 +29,10 @@ FLARE. If not, see http://www.gnu.org/licenses/
#include "MenuConfirm.h"
#include "SharedResources.h"
#include "Settings.h"
+#include "UtilsFileSystem.h"
#include "UtilsParsing.h"
#include "WidgetLabel.h"
+#include "WidgetTooltip.h"
#include <algorithm>
@@ -178,6 +180,11 @@ GameStateLoad::GameStateLoad() : GameState() {
frame_ticker = 0;
color_normal = font->getColor("menu_normal");
+
+ tip = new WidgetTooltip();
+ tipdata = new TooltipData();
+ tipdata->num_lines = 1;
+ use_story_warning = false;
}
void GameStateLoad::loadGraphics() {
@@ -415,22 +422,9 @@ void GameStateLoad::logic() {
if (inpt->pressing[MAIN1] && !inpt->lock[MAIN1]) {
for (int i=0; i<GAME_SLOT_MAX; i++) {
if (isWithin(slot_pos[i], inpt->mouse)) {
- selected_slot = i;
inpt->lock[MAIN1] = true;
- loadPortrait(selected_slot);
-
- button_action->enabled = true;
- if (stats[selected_slot].name == "") {
- button_action->label = msg->get("New Game");
- button_alternate->enabled = false;
- }
- else {
- button_action->label = msg->get("Load Game");
- button_alternate->enabled = true;
- }
- button_action->refresh();
- button_alternate->refresh();
-
+ selected_slot = i;
+ updateButtons();
}
}
}
@@ -439,39 +433,13 @@ void GameStateLoad::logic() {
inpt->lock[DOWN] = true;
selected_slot += 1;
if (selected_slot > GAME_SLOT_MAX-1) selected_slot = GAME_SLOT_MAX-1;
-
- loadPortrait(selected_slot);
-
- button_action->enabled = true;
- if (stats[selected_slot].name == "") {
- button_action->label = msg->get("New Game");
- button_alternate->enabled = false;
- }
- else {
- button_action->label = msg->get("Load Game");
- button_alternate->enabled = true;
- }
- button_action->refresh();
- button_alternate->refresh();
+ updateButtons();
}
if (inpt->pressing[UP] && !inpt->lock[UP] && !inpt->lock[MAIN1]) {
inpt->lock[UP] = true;
selected_slot -= 1;
if (selected_slot < 0) selected_slot = 0;
-
- loadPortrait(selected_slot);
-
- button_action->enabled = true;
- if (stats[selected_slot].name == "") {
- button_action->label = msg->get("New Game");
- button_alternate->enabled = false;
- }
- else {
- button_action->label = msg->get("Load Game");
- button_alternate->enabled = true;
- }
- button_action->refresh();
- button_alternate->refresh();
+ updateButtons();
}
} else if (confirm->visible) {
confirm->logic();
@@ -485,16 +453,21 @@ void GameStateLoad::logic() {
loadPreview(selected_slot);
loadPortrait(selected_slot);
- button_alternate->enabled = false;
- button_alternate->refresh();
-
- button_action->label = msg->get("New Game");
- button_action->refresh();
+ updateButtons();
confirm->visible = false;
confirm->confirmClicked = false;
}
}
+
+ // tooltip handling
+ tipdata->lines[0] = "";
+ if (button_action->hover && !button_action->enabled && use_story_warning) {
+ tipdata->lines[0] = msg->get("Enable a story mod to continue");
+ }
+ if (button_alternate->hover && !button_alternate->enabled && use_story_warning) {
+ tipdata->lines[0] = msg->get("Enable a story mod to continue");
+ }
}
void GameStateLoad::logicLoading() {
@@ -508,6 +481,33 @@ void GameStateLoad::logicLoading() {
loading = false;
}
+void GameStateLoad::updateButtons() {
+ loadPortrait(selected_slot);
+
+ use_story_warning = false;
+ button_action->enabled = true;
+ if (stats[selected_slot].name == "") {
+ button_action->label = msg->get("New Game");
+ if (!fileExists(mods->locate("maps/spawn.txt"))) {
+ button_action->enabled = false;
+ use_story_warning = true;
+ }
+ button_alternate->enabled = false;
+ }
+ else {
+ button_alternate->enabled = true;
+ button_action->label = msg->get("Load Game");
+ if (current_map[selected_slot] == "") {
+ if (!fileExists(mods->locate("maps/spawn.txt"))) {
+ button_action->enabled = false;
+ use_story_warning = true;
+ }
+ }
+ }
+ button_action->refresh();
+ button_alternate->refresh();
+}
+
void GameStateLoad::render() {
SDL_Rect src;
@@ -604,8 +604,16 @@ void GameStateLoad::render() {
label_name[slot]->render();
}
}
+
+ // display tooltip
+ if (tipdata->lines[0] != "") {
+ tip->render(*tipdata, inpt->mouse, STYLE_FLOAT, screen);
+ }
+
// display warnings
if(confirm->visible) confirm->render();
+
+
}
GameStateLoad::~GameStateLoad() {
@@ -627,4 +635,6 @@ GameStateLoad::~GameStateLoad() {
}
delete label_loading;
delete confirm;
+ delete tip;
+ delete tipdata;
}
View
7 src/GameStateLoad.h
@@ -41,7 +41,8 @@ class ItemManager;
class MenuConfirm;
class WidgetButton;
class WidgetLabel;
-
+class WidgetTooltip;
+class TooltipData;
const int GAME_SLOT_MAX = 4;
@@ -51,6 +52,7 @@ class GameStateLoad : public GameState {
void loadGraphics();
void loadPortrait(int slot);
std::string getMapName(const std::string& map_filename);
+ void updateButtons();
ItemManager *items;
WidgetButton *button_exit;
@@ -60,6 +62,8 @@ class GameStateLoad : public GameState {
WidgetLabel *label_name[GAME_SLOT_MAX];
WidgetLabel *label_level[GAME_SLOT_MAX];
WidgetLabel *label_map[GAME_SLOT_MAX];
+ WidgetTooltip *tip;
+ TooltipData *tipdata;
MenuConfirm *confirm;
@@ -93,6 +97,7 @@ class GameStateLoad : public GameState {
SDL_Rect preview_pos;
SDL_Color color_normal;
+ bool use_story_warning;
public:
GameStateLoad();
View
27 src/GameStateTitle.cpp
@@ -24,6 +24,7 @@ FLARE. If not, see http://www.gnu.org/licenses/
#include "Settings.h"
#include "WidgetButton.h"
#include "WidgetLabel.h"
+#include "WidgetTooltip.h"
GameStateTitle::GameStateTitle() : GameState() {
@@ -40,6 +41,7 @@ GameStateTitle::GameStateTitle() : GameState() {
button_play->label = msg->get("Play Game");
button_play->pos.x = VIEW_W_HALF - button_play->pos.w/2;
button_play->pos.y = VIEW_H - (button_exit->pos.h*3);
+ if (!ENABLE_PLAYGAME) button_play->enabled = false;
button_play->refresh();
button_cfg->label = msg->get("Configuration");
@@ -55,6 +57,11 @@ GameStateTitle::GameStateTitle() : GameState() {
// set up labels
label_version = new WidgetLabel();
label_version->set(VIEW_W, 0, JUSTIFY_RIGHT, VALIGN_TOP, msg->get("Flare Alpha v0.17"), font->getColor("menu_normal"));
+
+ // set up tooltip
+ tip = new WidgetTooltip();
+ tipdata = new TooltipData();
+ tipdata->num_lines = 1;
}
void GameStateTitle::loadGraphics() {
@@ -73,6 +80,7 @@ void GameStateTitle::loadGraphics() {
}
void GameStateTitle::logic() {
+
if (ENABLE_PLAYGAME) {
button_play->enabled = true;
if (inpt->pressing[ACCEPT] && !inpt->lock[ACCEPT]) {
@@ -83,10 +91,9 @@ void GameStateTitle::logic() {
inpt->lock[CANCEL] = true;
exitRequested = true;
}
- } else {
- button_play->enabled = false;
}
+
if (button_play->checkClick()) {
delete requestedGameState;
requestedGameState = new GameStateLoad();
@@ -96,6 +103,14 @@ void GameStateTitle::logic() {
} else if (button_exit->checkClick()) {
exitRequested = true;
}
+
+ // handle tooltip
+ if (!ENABLE_PLAYGAME && button_play->hover) {
+ tipdata->lines[0] = msg->get("Enable a core mod to continue");
+ }
+ else {
+ tipdata->lines[0] = "";
+ }
}
void GameStateTitle::render() {
@@ -118,6 +133,12 @@ void GameStateTitle::render() {
// version number
label_version->render();
+
+ // display tooltip
+ if (tipdata->lines[0] != "") {
+ tip->render(*tipdata, inpt->mouse, STYLE_FLOAT, screen);
+ }
+
}
GameStateTitle::~GameStateTitle() {
@@ -126,4 +147,6 @@ GameStateTitle::~GameStateTitle() {
delete button_exit;
delete label_version;
SDL_FreeSurface(logo);
+ delete tip;
+ delete tipdata;
}
View
4 src/GameStateTitle.h
@@ -22,6 +22,8 @@ FLARE. If not, see http://www.gnu.org/licenses/
class WidgetButton;
class WidgetLabel;
+class WidgetTooltip;
+class TooltipData;
class GameStateTitle : public GameState {
private:
@@ -30,6 +32,8 @@ class GameStateTitle : public GameState {
WidgetButton *button_exit;
WidgetButton *button_cfg;
WidgetLabel *label_version;
+ WidgetTooltip *tip;
+ TooltipData *tipdata;
public:
GameStateTitle();
View
8 src/MapRenderer.cpp
@@ -882,8 +882,8 @@ void MapRenderer::renderIso(vector<Renderable> &r, vector<Renderable> &r_dead) {
src.h = 2 * VIEW_H;
SDL_BlitSurface(backgroundsurface, &src, screen , 0);
}
- renderIsoBackObjects(r_dead);
- renderIsoFrontObjects(r);
+ if (object) renderIsoBackObjects(r_dead);
+ if (object) renderIsoFrontObjects(r);
if (foreground) renderIsoLayer(screen, nulloffset, foreground);
checkTooltip();
}
@@ -952,8 +952,8 @@ void MapRenderer::renderOrthoFrontObjects(std::vector<Renderable> &r) {
void MapRenderer::renderOrtho(vector<Renderable> &r, vector<Renderable> &r_dead) {
if (background) renderOrthoLayer(background);
if (fringe) renderOrthoLayer(fringe);
- renderOrthoBackObjects(r_dead);
- renderOrthoFrontObjects(r);
+ if (object) renderOrthoBackObjects(r_dead);
+ if (object) renderOrthoFrontObjects(r);
if (foreground) renderOrthoLayer(foreground);
//render event tooltips
checkTooltip();
View
21 src/MenuManager.cpp
@@ -236,7 +236,7 @@ void MenuManager::logic() {
// only allow the vendor window to be open if the inventory is open
if (vendor->visible && !(inv->visible)) {
- closeLeft(true);
+ closeLeft(false);
if (vendor->talker_visible && !(inv->visible))
closeRight(true);
}
@@ -431,20 +431,10 @@ void MenuManager::logic() {
// pick up an inventory item
if (inv->visible && isWithin(inv->window_area,inpt->mouse)) {
if (inpt->pressing[CTRL]) {
- vendor->setTab(VENDOR_SELL);
inpt->lock[MAIN1] = true;
stack = inv->click(inpt);
if( stack.item > 0) {
- if (vendor->visible) {
- // The vendor could have a limited amount of money in the future. It will be tested here.
- if (inv->sell(stack)) {
- vendor->add(stack);
- }
- else {
- inv->itemReturn(stack);
- }
- }
- else if (stash->visible) {
+ if (stash->visible) {
if (inv->stashAdd(stack) && !stash->full(stack.item)) {
stash->add(stack);
stash->updated = true;
@@ -454,7 +444,12 @@ void MenuManager::logic() {
}
}
else {
- if (!inv->sell(stack)) {
+ // The vendor could have a limited amount of money in the future. It will be tested here.
+ if ((SELL_WITHOUT_VENDOR || vendor->visible) && inv->sell(stack)) {
+ vendor->setTab(VENDOR_SELL);
+ vendor->add(stack);
+ }
+ else {
inv->itemReturn(stack);
}
}
View
2 src/MenuVendor.cpp
@@ -217,7 +217,7 @@ void MenuVendor::setInventory() {
*/
void MenuVendor::saveInventory() {
for (int i=0; i<VENDOR_SLOTS; i++) {
- npc->stock[i] = stock[VENDOR_BUY][i];
+ if (npc) npc->stock[i] = stock[VENDOR_BUY][i];
buyback_stock[i] = stock[VENDOR_SELL][i];
}
View
3 src/Settings.cpp
@@ -155,6 +155,7 @@ bool SAVE_HPMP = false;
bool ENABLE_PLAYGAME = false;
bool SHOW_FPS = false;
int CORPSE_TIMEOUT = 1800;
+bool SELL_WITHOUT_VENDOR = true;
/**
@@ -345,6 +346,8 @@ void loadMiscSettings() {
DEFAULT_NAME = infile.val.c_str();
} else if (infile.key == "corpse_timeout") {
CORPSE_TIMEOUT = toInt(infile.val);
+ } else if (infile.key == "sell_without_vendor") {
+ SELL_WITHOUT_VENDOR = toInt(infile.val);
}
}
infile.close();
View
1 src/Settings.h
@@ -82,6 +82,7 @@ extern bool SAVE_HPMP;
extern bool ENABLE_PLAYGAME;
extern bool SHOW_FPS;
extern int CORPSE_TIMEOUT;
+extern bool SELL_WITHOUT_VENDOR;
// Tile Settings
extern unsigned short UNITS_PER_TILE;

0 comments on commit 838a78c

Please sign in to comment.
Something went wrong with that request. Please try again.