Commit patch from ticket:2110 "Mousewheel menu patch"

Author: noccy
Thanks for the patch!

Format and additional changes by me.

Close ticket:2110
(cherry picked from commit e979b6ad620f27e746f119fefd1f613bbb61b8a4)

Conflicts:

	src/keybind.c
	src/keybind.h
master
buginator 2010-10-21 00:55:55 -04:00
parent 40c5ace37b
commit d0217d5d4e
5 changed files with 151 additions and 3 deletions

View File

@ -788,7 +788,7 @@ static BOOL formPickHTab(TAB_POS *psTabPos,
// Also need to check if the TabMultiplier is set or not, if not then it means
// we have not yet added the code to display/handle the tab scroll buttons.
// At this time, I think only the design screen has this limitation of only 8 tabs.
if (number > MAX_TAB_SMALL_SHOWN && psTabPos->TabMultiplier) // of course only do this if we actually need >8 tabs.
if (number > (MAX_TAB_SMALL_SHOWN - 1) && psTabPos->TabMultiplier) // of course only do this if we actually need >8 tabs.
{
number -= (psTabPos->TabMultiplier - 1) * TAB_SEVEN;
if (number > TAB_SEVEN) // is it still > than TAB_SEVEN?
@ -1337,7 +1337,7 @@ static void formDisplayTTabs(W_TABFORM *psForm,SDWORD x0, SDWORD y0,
x = x0 + 2;
x1 = x + width - 2;
y1 = y0 + height;
if (number > MAX_TAB_SMALL_SHOWN) //we can display 8 tabs fine with no extra voodoo.
if (number > (MAX_TAB_SMALL_SHOWN - 1)) //we can display 8 tabs fine with no extra voodoo.
{ // We do NOT want to draw all the tabs once we have drawn 7 tabs
// Both selected & hilite are converted from virtual tab range, to a range
// that is seen on the form itself. This would be 0-6 (7 tabs)

View File

@ -460,6 +460,8 @@ void resetInput(void)
void processInput(void)
{
BOOL mOverRadar = false;
BOOL mOverConstruction = false;
int WheelZoomIterator;
if (InGameOpUp || isInGamePopupUp)
@ -472,6 +474,11 @@ void processInput(void)
mOverRadar = true;
}
if(CoordInBuild(mouseX(), mouseY()))
{
mOverConstruction = true;
}
StartOfLastFrame = currentFrame;
currentFrame = frameGetFrameNumber();
@ -494,6 +501,10 @@ void processInput(void)
{
kf_RadarZoomIn();
}
else if (mOverConstruction)
{
kf_BuildPrevPage();
}
else
{
for (WheelZoomIterator = 0; WheelZoomIterator < 10; WheelZoomIterator++)
@ -513,6 +524,10 @@ void processInput(void)
{
kf_RadarZoomOut();
}
else if (mOverConstruction)
{
kf_BuildNextPage();
}
else
{
for (WheelZoomIterator = 0; WheelZoomIterator < 10; WheelZoomIterator++)

View File

@ -1550,14 +1550,20 @@ static void intProcessEditStats(UDWORD id)
if (psTForm->TabMultiplier < 1 )
{
psTForm->TabMultiplier = 1; //Must be at least 1.
audio_PlayTrack(ID_SOUND_BUILD_FAIL);
}
// add routine to update tab widgets now...
temp = psTForm->majorT; //set tab # to previous "page"
temp -=TAB_SEVEN; //7 = 1 "page" of tabs
if ( temp < 0)
{
psTForm->majorT = 0;
audio_PlayTrack(ID_SOUND_BUILD_FAIL);
}
else
{
psTForm->majorT = temp;
}
#ifdef DEBUG_SCROLLTABS
sprintf(buf,"[debug menu]Clicked LT %d tab #=%d",psTForm->TabMultiplier,psTForm->majorT);
addConsoleMessage(buf,DEFAULT_JUSTIFY,SYSTEM_MESSAGE);
@ -1577,6 +1583,7 @@ static void intProcessEditStats(UDWORD id)
if (psTForm->TabMultiplier > numTabs) // add 'Bzzt' sound effect?
{
psTForm->TabMultiplier -= 1; // to signify past max?
audio_PlayTrack(ID_SOUND_BUILD_FAIL);
}
//add routine to update tab widgets now...
psTForm->majorT += TAB_SEVEN; // set tab # to next "page"
@ -3049,6 +3056,7 @@ static void intProcessStats(UDWORD id)
if (psTForm->TabMultiplier < 1)
{
psTForm->TabMultiplier = 1; // Must be at least 1.
audio_PlayTrack(ID_SOUND_BUILD_FAIL);
}
//add routine to update tab widgets now...
temp = psTForm->majorT; // set tab # to previous "page"
@ -3076,6 +3084,7 @@ static void intProcessStats(UDWORD id)
if (psTForm->TabMultiplier > numTabs) //add 'Bzzt' sound effect?
{
psTForm->TabMultiplier -= 1; //to signify past max?
audio_PlayTrack(ID_SOUND_BUILD_FAIL);
}
//add routine to update tab widgets now...
psTForm->majorT += TAB_SEVEN; // set tab # to next "page"
@ -7286,3 +7295,24 @@ BASE_OBJECT * getCurrentSelected(void)
{
return psObjSelected;
}
// Checks if a coordinate is over the build menu
BOOL CoordInBuild(int x, int y)
{
// This measurement is valid for the menu, so the buildmenu_height
// value is used to "nudge" it all upwards from the command menu.
// FIXME: hardcoded value (?)
const int buildmenu_height = 300;
Vector2f pos;
pos.x = x - RET_X;
pos.y = y - RET_Y + buildmenu_height; // guesstimation
if (pos.x < 0 || pos.y < 0 || pos.x >= RET_FORMWIDTH || pos.y >= buildmenu_height)
{
return false;
}
return true;
}

View File

@ -99,7 +99,9 @@
Alex McLean, Pumpkin Studios, EIDOS Interactive.
*/
#define MAP_ZOOM_RATE (1250)
//#define DEBUG_SCROLLTABS //enable to see tab scroll button info for buttons
#define MAP_ZOOM_RATE (1000)
#define MAP_PITCH_RATE (SPIN_SCALING/SECS_PER_SPIN)
extern char ScreenDumpPath[];
@ -2899,3 +2901,101 @@ void kf_ToggleLogical()
{
console("Logical updates can no longer be toggled."); // TODO remove me
}
// rotuine to decrement the tab-scroll 'buttons'
void kf_BuildPrevPage()
{
W_TABFORM *psTForm;
int temp;
int numTabs;
int maxTabs;
int tabPos;
ASSERT_OR_RETURN( , psWScreen != NULL, " Invalid screen pointer!");
psTForm = (W_TABFORM *)widgGetFromID(psWScreen, IDSTAT_TABFORM); //get our form
if (psTForm == NULL)
{
return;
}
if (psTForm->TabMultiplier < 1)
{
psTForm->TabMultiplier = 1; // 1-based
}
numTabs = numForms(psTForm->numStats,psTForm->numButtons);
maxTabs = ((numTabs /TAB_SEVEN) + 1); // (Total tabs needed / 7(max tabs that fit))+1
temp = psTForm->majorT - 1;
if (temp < 0)
{
temp = 0 ;
audio_PlayTrack(ID_SOUND_BUILD_FAIL);
return;
}
psTForm->majorT = temp;
tabPos = ((psTForm->majorT) % TAB_SEVEN); // The tabs position on the page
if ((tabPos == (TAB_SEVEN - 1)) && (psTForm->TabMultiplier > 1))
{
psTForm->TabMultiplier -= 1;
}
audio_PlayTrack(ID_SOUND_BUTTON_CLICK_5);
#ifdef DEBUG_SCROLLTABS
console("Tabs: %d - MaxTabs: %d - MajorT: %d - numMajor: %d - TabMultiplier: %d",numTabs, maxTabs, psTForm->majorT, psTForm->numMajor, psTForm->TabMultiplier);
#endif
}
// rotuine to advance the tab-scroll 'buttons'
void kf_BuildNextPage()
{
W_TABFORM *psTForm;
int numTabs;
int maxTabs;
int tabPos;
ASSERT_OR_RETURN( , psWScreen != NULL, " Invalid screen pointer!");
psTForm = (W_TABFORM *)widgGetFromID(psWScreen, IDSTAT_TABFORM);
if (psTForm == NULL)
{
return;
}
if (psTForm->TabMultiplier < 1)
{
psTForm->TabMultiplier = 1; // 1-based
audio_PlayTrack(ID_SOUND_BUILD_FAIL);
}
numTabs = numForms(psTForm->numStats,psTForm->numButtons);
maxTabs = ((numTabs /TAB_SEVEN)); // (Total tabs needed / 7(max tabs that fit))+1
if (psTForm->majorT < numTabs - 1)
{
// Increase tab if we are not on the last one
psTForm->majorT += 1; // set tab # to next "page"
}
else
{
// went over max
audio_PlayTrack(ID_SOUND_BUILD_FAIL);
return;
}
tabPos = ((psTForm->majorT) % TAB_SEVEN); // The tabs position on the page
// 7 mod 7 = 0, since we are going forward we can assume it's the next tab
if ((tabPos == 0) && (psTForm->TabMultiplier <= maxTabs))
{
psTForm->TabMultiplier += 1;
}
if (psTForm->majorT >= psTForm->numMajor)
{
psTForm->majorT = psTForm->numMajor - 1;
}
audio_PlayTrack( ID_SOUND_BUTTON_CLICK_5 );
#ifdef DEBUG_SCROLLTABS
console("Tabs: %d - MaxTabs: %d - MajorT: %d - numMajor: %d - TabMultiplier: %d",numTabs, maxTabs, psTForm->majorT, psTForm->numMajor, psTForm->TabMultiplier);
#endif
}

View File

@ -256,9 +256,12 @@ bool runningMultiplayer(void);
void kf_ForceSync( void );
void kf_ForceDesync(void);
void kf_PowerInfo( void );
void kf_BuildNextPage( void );
void kf_BuildPrevPage( void );
#ifdef __cplusplus
}
#endif //__cplusplus
#endif // __INCLUDED_SRC_KEYBIND_H__