mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 14:01:45 +00:00
- redid mouse control for the conversation menu.
Since the page operates on different coordinate systems, the only working way to check the mouse is to store the real coordinates when drawing and check the mouse position against those.
This commit is contained in:
parent
b441b649c4
commit
328d9c75c4
1 changed files with 9 additions and 11 deletions
|
@ -93,7 +93,7 @@ class ConversationMenu : Menu
|
||||||
int fontScale;
|
int fontScale;
|
||||||
int refwidth;
|
int refwidth;
|
||||||
int refheight;
|
int refheight;
|
||||||
double fontfactor;
|
Array<double> ypositions;
|
||||||
|
|
||||||
int SpeechWidth;
|
int SpeechWidth;
|
||||||
int ReplyWidth;
|
int ReplyWidth;
|
||||||
|
@ -127,7 +127,6 @@ class ConversationMenu : Menu
|
||||||
displayWidth = CleanWidth;
|
displayWidth = CleanWidth;
|
||||||
displayHeight = CleanHeight;
|
displayHeight = CleanHeight;
|
||||||
fontScale = CleanXfac;
|
fontScale = CleanXfac;
|
||||||
fontFactor = 1;
|
|
||||||
refwidth = 320;
|
refwidth = 320;
|
||||||
refheight = 200;
|
refheight = 200;
|
||||||
ReplyWidth = 320-50-10;
|
ReplyWidth = 320-50-10;
|
||||||
|
@ -140,7 +139,6 @@ class ConversationMenu : Menu
|
||||||
{
|
{
|
||||||
displayFont = NewSmallFont;
|
displayFont = NewSmallFont;
|
||||||
fontScale = (CleanXfac+1) / 2;
|
fontScale = (CleanXfac+1) / 2;
|
||||||
fontFactor = double(CleanXfac) / fontScale;
|
|
||||||
refwidth = 640;
|
refwidth = 640;
|
||||||
refheight = 400;
|
refheight = 400;
|
||||||
ReplyWidth = 640-100-20;
|
ReplyWidth = 640-100-20;
|
||||||
|
@ -365,18 +363,14 @@ class ConversationMenu : Menu
|
||||||
|
|
||||||
// convert x/y from screen to virtual coordinates, according to CleanX/Yfac use in DrawTexture
|
// convert x/y from screen to virtual coordinates, according to CleanX/Yfac use in DrawTexture
|
||||||
x = ((x - (screen.GetWidth() / 2)) / fontScale) + refWidth/2;
|
x = ((x - (screen.GetWidth() / 2)) / fontScale) + refWidth/2;
|
||||||
y = ((y - (screen.GetHeight() / 2)) / fontScale) + refHeight/2;
|
|
||||||
|
|
||||||
int ypos = int(mYpos * FontFactor);
|
if (x >= 24 && x <= refWidth-24)
|
||||||
|
|
||||||
if (x >= 24 && x <= refWidth-24 && y >= ypos && y < ypos + fh * mResponseLines.Size())
|
|
||||||
{
|
{
|
||||||
sel = (y - ypos) / fh;
|
for (int i = 0; i < ypositions.Size()-1; i++)
|
||||||
for(int i = 0; i < mResponses.Size(); i++)
|
|
||||||
{
|
{
|
||||||
if (mResponses[i] > sel)
|
if (y > ypositions[i] && y <= ypositions[i+1])
|
||||||
{
|
{
|
||||||
sel = i-1;
|
sel = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -498,6 +492,7 @@ class ConversationMenu : Menu
|
||||||
int y = mYpos;
|
int y = mYpos;
|
||||||
|
|
||||||
int response = 0;
|
int response = 0;
|
||||||
|
ypositions.Clear();
|
||||||
for (int i = 0; i < mResponseLines.Size(); i++)
|
for (int i = 0; i < mResponseLines.Size(); i++)
|
||||||
{
|
{
|
||||||
int width = displayFont.StringWidth(mResponseLines[i]);
|
int width = displayFont.StringWidth(mResponseLines[i]);
|
||||||
|
@ -506,6 +501,7 @@ class ConversationMenu : Menu
|
||||||
double sx = (x - 160.0) * CleanXfac + (screen.GetWidth() * 0.5);
|
double sx = (x - 160.0) * CleanXfac + (screen.GetWidth() * 0.5);
|
||||||
double sy = (y - 100.0) * CleanYfac + (screen.GetHeight() * 0.5);
|
double sy = (y - 100.0) * CleanYfac + (screen.GetHeight() * 0.5);
|
||||||
|
|
||||||
|
ypositions.Push(sy);
|
||||||
|
|
||||||
screen.DrawText(displayFont, Font.CR_GREEN, sx / fontScale, sy / fontScale, mResponseLines[i], DTA_KeepRatio, true, DTA_VirtualWidth, displayWidth, DTA_VirtualHeight, displayHeight);
|
screen.DrawText(displayFont, Font.CR_GREEN, sx / fontScale, sy / fontScale, mResponseLines[i], DTA_KeepRatio, true, DTA_VirtualWidth, displayWidth, DTA_VirtualHeight, displayHeight);
|
||||||
|
|
||||||
|
@ -530,6 +526,8 @@ class ConversationMenu : Menu
|
||||||
}
|
}
|
||||||
y += ReplyLineHeight;
|
y += ReplyLineHeight;
|
||||||
}
|
}
|
||||||
|
double sy = (y - 100.0) * CleanYfac + (screen.GetHeight() * 0.5);
|
||||||
|
ypositions.Push(sy);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void DrawGold()
|
virtual void DrawGold()
|
||||||
|
|
Loading…
Reference in a new issue