File confec.cpp changed (mode: 100644) (index bb8cd86..87c44a7) |
... |
... |
struct SpecialItem { |
378 |
378 |
int32_t special_item_result = 0; |
int32_t special_item_result = 0; |
379 |
379 |
|
|
380 |
380 |
// App variable definitions. |
// App variable definitions. |
381 |
|
std::string app_version = "v0.7.10"; |
|
|
381 |
|
std::string app_version = "v0.7.11"; |
382 |
382 |
#ifdef __DEMO__ |
#ifdef __DEMO__ |
383 |
383 |
app_version += " demo"; |
app_version += " demo"; |
384 |
384 |
std::string app_name = "Confectioner Engine Demo"; |
std::string app_name = "Confectioner Engine Demo"; |
|
... |
... |
float dead_zone = 0.1f, speed_zone = 0.9f; |
486 |
486 |
float stickX = 0.0f, stickY = 0.0f, moveX = 0.0f, moveY = 0.0f; |
float stickX = 0.0f, stickY = 0.0f, moveX = 0.0f, moveY = 0.0f; |
487 |
487 |
int moveXInt = 0, moveYInt = 0, moveXDown = 0, moveYDown = 0; |
int moveXInt = 0, moveYInt = 0, moveXDown = 0, moveYDown = 0; |
488 |
488 |
bool |
bool |
489 |
|
actionButton = false, actionButtonDown = false, |
|
490 |
|
interactButton = false, interactButtonDown = false, |
|
|
489 |
|
actionButton = false, actionButtonDown = false, actionButtonUp = false, |
|
490 |
|
interactButton = false, interactButtonDown = false, interactButtonUp = false, |
491 |
491 |
recipesButton = false, recipesButtonDown = false, |
recipesButton = false, recipesButtonDown = false, |
492 |
492 |
meleeButton = false, meleeButtonDown = false, |
meleeButton = false, meleeButtonDown = false, |
493 |
493 |
entityButton = false, entityButtonDown = false, |
entityButton = false, entityButtonDown = false, |
|
... |
... |
void Render(){ |
4377 |
4377 |
static bool actionButtonLast; |
static bool actionButtonLast; |
4378 |
4378 |
actionButton = fgl::enterKey() || fgl::aButton(); |
actionButton = fgl::enterKey() || fgl::aButton(); |
4379 |
4379 |
actionButtonDown = actionButton && !actionButtonLast; |
actionButtonDown = actionButton && !actionButtonLast; |
|
4380 |
|
actionButtonUp = !actionButton && actionButtonLast; |
4380 |
4381 |
actionButtonLast = actionButton; |
actionButtonLast = actionButton; |
4381 |
4382 |
|
|
4382 |
4383 |
// In-game and menu interaction. |
// In-game and menu interaction. |
4383 |
4384 |
static bool interactButtonLast; |
static bool interactButtonLast; |
4384 |
4385 |
interactButton = GetButtonState( k_interact ) || ( actionButton && (inputTarget || !show_cursor) ); |
interactButton = GetButtonState( k_interact ) || ( actionButton && (inputTarget || !show_cursor) ); |
4385 |
4386 |
interactButtonDown = interactButton && !interactButtonLast; |
interactButtonDown = interactButton && !interactButtonLast; |
|
4387 |
|
interactButtonUp = !interactButton && interactButtonLast; |
4386 |
4388 |
interactButtonLast = interactButton; |
interactButtonLast = interactButton; |
4387 |
4389 |
|
|
4388 |
4390 |
static bool recipesButtonLast; |
static bool recipesButtonLast; |
|
... |
... |
void DrawCharacterSelect(){ |
5134 |
5136 |
} |
} |
5135 |
5137 |
offset_x += increment_x; |
offset_x += increment_x; |
5136 |
5138 |
if( ( hover && mouseUpLeft ) |
if( ( hover && mouseUpLeft ) |
5137 |
|
|| ( (size_t)choiceIndex == i && (actionButtonDown || interactButtonDown) ) ){ |
|
|
5139 |
|
|| ( (size_t)choiceIndex == i && (actionButtonUp || interactButtonUp) ) ){ |
5138 |
5140 |
// Do not propagate the click or button press. |
// Do not propagate the click or button press. |
5139 |
5141 |
mouseUpLeft = false; |
mouseUpLeft = false; |
5140 |
5142 |
actionButtonDown = false; |
actionButtonDown = false; |
|
5143 |
|
actionButtonUp = false; |
5141 |
5144 |
interactButtonDown = false; |
interactButtonDown = false; |
|
5145 |
|
interactButtonUp = false; |
5142 |
5146 |
character_select_display = false; |
character_select_display = false; |
5143 |
5147 |
character_selected = item_ptr->entity.itemName; |
character_selected = item_ptr->entity.itemName; |
5144 |
5148 |
// Clear every drawing buffer, even with triple buffering. |
// Clear every drawing buffer, even with triple buffering. |
|
... |
... |
void GameLoop( double d ){ |
5827 |
5831 |
auto &ent = world.entities[world.facingEntity]; |
auto &ent = world.entities[world.facingEntity]; |
5828 |
5832 |
if( ent.task != fworld::TASK_SLEEP || ent.type != "regrow" ) |
if( ent.task != fworld::TASK_SLEEP || ent.type != "regrow" ) |
5829 |
5833 |
target_name = ent.name; |
target_name = ent.name; |
5830 |
|
if( interactButtonDown ){ |
|
|
5834 |
|
if( interactButtonUp ){ |
5831 |
5835 |
// Do not propagate the button press. |
// Do not propagate the button press. |
5832 |
|
interactButtonDown = false; |
|
5833 |
5836 |
actionButtonDown = false; |
actionButtonDown = false; |
|
5837 |
|
actionButtonUp = false; |
|
5838 |
|
interactButtonDown = false; |
|
5839 |
|
interactButtonUp = false; |
|
5840 |
|
// Do not propagate the click either, as left-clicking |
|
5841 |
|
// is triggered by controller mouse emulation. |
|
5842 |
|
mouseUpLeft = false; |
5834 |
5843 |
// Trigger an interaction. |
// Trigger an interaction. |
5835 |
5844 |
WorldInteract( world.facingEntity ); |
WorldInteract( world.facingEntity ); |
5836 |
5845 |
} |
} |
|
... |
... |
void GameLoop( double d ){ |
5858 |
5867 |
// If there is interaction, do not propagate the click. |
// If there is interaction, do not propagate the click. |
5859 |
5868 |
mouseUpLeft = |
mouseUpLeft = |
5860 |
5869 |
!WorldInteract( world.cursorOverEntity ); |
!WorldInteract( world.cursorOverEntity ); |
|
5870 |
|
// Mouse-up cancellation trickles down to possible constituent button-up states. |
|
5871 |
|
if( actionButtonUp ) actionButtonUp = mouseUpLeft; |
|
5872 |
|
if( interactButtonUp ) interactButtonUp = mouseUpLeft; |
5861 |
5873 |
} |
} |
5862 |
5874 |
} |
} |
5863 |
5875 |
|
|
|
... |
... |
void GameLoop( double d ){ |
6072 |
6084 |
convo, |
convo, |
6073 |
6085 |
choiceIndex, |
choiceIndex, |
6074 |
6086 |
moveXDown + moveYDown, |
moveXDown + moveYDown, |
6075 |
|
mouseLeft || mouseUpLeft, |
|
6076 |
|
mouseUpLeft || actionButtonDown || interactButtonDown, |
|
|
6087 |
|
show_cursor, |
|
6088 |
|
mouseLeft || actionButton || interactButton, |
|
6089 |
|
mouseUpLeft || actionButtonUp || interactButtonUp, |
6077 |
6090 |
pauseButtonDown ) ){ |
pauseButtonDown ) ){ |
6078 |
6091 |
// Do not propagate the click or button press. |
// Do not propagate the click or button press. |
6079 |
6092 |
mouseUpLeft = false; |
mouseUpLeft = false; |
6080 |
6093 |
actionButtonDown = false; |
actionButtonDown = false; |
|
6094 |
|
actionButtonUp = false; |
6081 |
6095 |
interactButtonDown = false; |
interactButtonDown = false; |
|
6096 |
|
interactButtonUp = false; |
6082 |
6097 |
} |
} |
6083 |
6098 |
|
|
6084 |
6099 |
// HUD. |
// HUD. |
File include/vn.h changed (mode: 100644) (index e1a9c8c..08ceef6) |
... |
... |
bool vnDraw( |
124 |
124 |
int &choiceIndex, |
int &choiceIndex, |
125 |
125 |
int choiceMove, |
int choiceMove, |
126 |
126 |
bool useMouse, |
bool useMouse, |
|
127 |
|
bool pressing, |
127 |
128 |
bool activate, |
bool activate, |
128 |
129 |
bool &pauseButtonDown ){ |
bool &pauseButtonDown ){ |
129 |
130 |
double sw = fgl::getDisplayWidth(), sh = fgl::getDisplayHeight(); |
double sw = fgl::getDisplayWidth(), sh = fgl::getDisplayHeight(); |
|
... |
... |
bool vnDraw( |
253 |
254 |
|
|
254 |
255 |
if( convo.screen.lines.empty() ){ |
if( convo.screen.lines.empty() ){ |
255 |
256 |
// Handle button-free screen advance. |
// Handle button-free screen advance. |
256 |
|
choiceIndex = 0; |
|
|
257 |
|
if( convo.screen.ids.size() > 0 ) choiceIndex = 0; |
257 |
258 |
}else if( convo.screen.lines[0].length() > 4 |
}else if( convo.screen.lines[0].length() > 4 |
258 |
259 |
&& convo.screen.lines[0].substr( 0, 4 ) == "img-" ){ |
&& convo.screen.lines[0].substr( 0, 4 ) == "img-" ){ |
259 |
260 |
// Draw image buttons. |
// Draw image buttons. |
|
... |
... |
bool vnDraw( |
272 |
273 |
for( size_t i = 0; i < img_buttons.size(); i++ ){ |
for( size_t i = 0; i < img_buttons.size(); i++ ){ |
273 |
274 |
auto w = img_buttons[i]->width, h = img_buttons[i]->height; |
auto w = img_buttons[i]->width, h = img_buttons[i]->height; |
274 |
275 |
bool hover = |
bool hover = |
275 |
|
//useMouse && |
|
|
276 |
|
useMouse && |
276 |
277 |
fgl::mouseY >= ypos && |
fgl::mouseY >= ypos && |
277 |
278 |
fgl::mouseY < ypos + ( h + 2.0 ) * vnScale && |
fgl::mouseY < ypos + ( h + 2.0 ) * vnScale && |
278 |
279 |
fgl::mouseX >= xpos && |
fgl::mouseX >= xpos && |
|
... |
... |
bool vnDraw( |
282 |
283 |
} |
} |
283 |
284 |
if( i == (size_t)choiceIndex ){ |
if( i == (size_t)choiceIndex ){ |
284 |
285 |
// Draw an outline. |
// Draw an outline. |
285 |
|
if( useMouse ) |
|
|
286 |
|
if( pressing ) |
286 |
287 |
fgl::setFog( { 0.0f, 0.9f, 1.0f, 999.0f } ); |
fgl::setFog( { 0.0f, 0.9f, 1.0f, 999.0f } ); |
287 |
288 |
else |
else |
288 |
289 |
fgl::setFog( { 1.0f, 1.0f, 1.0f, 999.0f } ); |
fgl::setFog( { 1.0f, 1.0f, 1.0f, 999.0f } ); |
|
... |
... |
bool vnDraw( |
329 |
330 |
for( size_t i = 0; i < convo.screen.ids.size(); i++ ){ |
for( size_t i = 0; i < convo.screen.ids.size(); i++ ){ |
330 |
331 |
float ypos = ( vn_height * 0.7409 + buttonHeight * (float)i ) * vnScale; |
float ypos = ( vn_height * 0.7409 + buttonHeight * (float)i ) * vnScale; |
331 |
332 |
bool hover = |
bool hover = |
332 |
|
//useMouse && |
|
|
333 |
|
useMouse && |
333 |
334 |
fgl::mouseY >= ypos && |
fgl::mouseY >= ypos && |
334 |
335 |
fgl::mouseY < ( vn_height * 0.7409 + buttonHeight * (float)( i + 1 ) ) * vnScale && |
fgl::mouseY < ( vn_height * 0.7409 + buttonHeight * (float)( i + 1 ) ) * vnScale && |
335 |
336 |
fgl::mouseX >= vnOffX && |
fgl::mouseX >= vnOffX && |
|
... |
... |
bool vnDraw( |
340 |
341 |
// Draw button. |
// Draw button. |
341 |
342 |
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); |
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); |
342 |
343 |
vnDrawImage( |
vnDrawImage( |
343 |
|
i == (size_t)choiceIndex ? (useMouse ? vn_tex_button_p : vn_tex_button_s) : vn_tex_button_n, |
|
|
344 |
|
i == (size_t)choiceIndex ? (pressing ? vn_tex_button_p : vn_tex_button_s) : vn_tex_button_n, |
344 |
345 |
vnOffX, |
vnOffX, |
345 |
346 |
ypos, |
ypos, |
346 |
347 |
0.0, |
0.0, |