mirror of
https://github.com/dborth/fceugx.git
synced 2024-10-31 22:45:05 +01:00
draggable scrollbar, video fix
This commit is contained in:
parent
cfbbe9a21d
commit
d32a852154
@ -195,7 +195,7 @@ LoadRAMAuto (int method, bool silent)
|
||||
return true;
|
||||
|
||||
// look for file with no number or Auto appended
|
||||
if(!MakeFilePath(filepath2, action, method, romFilename, -1))
|
||||
if(!MakeFilePath(filepath2, FILE_RAM, method, romFilename, -1))
|
||||
return false;
|
||||
|
||||
if(LoadRAM(filepath2, method, silent))
|
||||
|
@ -648,7 +648,7 @@ ResetVideo_Emu ()
|
||||
GX_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE);
|
||||
GX_SetColorUpdate (GX_TRUE);
|
||||
|
||||
guOrtho(p, rmode->efbHeight/2, -(rmode->efbHeight/2), -(rmode->fbWidth/2), rmode->fbWidth/2, 100, 1000); // matrix, t, b, l, r, n, f
|
||||
guOrtho(p, 480/2, -(480/2), -(640/2), 640/2, 100, 1000); // matrix, t, b, l, r, n, f
|
||||
GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC);
|
||||
|
||||
// reinitialize texture
|
||||
|
@ -73,6 +73,7 @@ enum
|
||||
STATE_DEFAULT,
|
||||
STATE_SELECTED,
|
||||
STATE_CLICKED,
|
||||
STATE_HELD,
|
||||
STATE_DISABLED
|
||||
};
|
||||
|
||||
@ -157,6 +158,30 @@ class GuiElement
|
||||
//!Considers vertical alignment, y offset, height, and parent element's GetTop() / GetHeight() values
|
||||
//!\return top coordinate
|
||||
int GetTop();
|
||||
//!Sets the minimum y offset of the element
|
||||
//!\param y Y offset
|
||||
void SetMinY(int y);
|
||||
//!Gets the minimum y offset of the element
|
||||
//!\return Minimum Y offset
|
||||
int GetMinY();
|
||||
//!Sets the maximum y offset of the element
|
||||
//!\param y Y offset
|
||||
void SetMaxY(int y);
|
||||
//!Gets the maximum y offset of the element
|
||||
//!\return Maximum Y offset
|
||||
int GetMaxY();
|
||||
//!Sets the minimum x offset of the element
|
||||
//!\param x X offset
|
||||
void SetMinX(int x);
|
||||
//!Gets the minimum x offset of the element
|
||||
//!\return Minimum X offset
|
||||
int GetMinX();
|
||||
//!Sets the maximum x offset of the element
|
||||
//!\param x X offset
|
||||
void SetMaxX(int x);
|
||||
//!Gets the maximum x offset of the element
|
||||
//!\return Maximum X offset
|
||||
int GetMaxX();
|
||||
//!Gets the current width of the element. Does not currently consider the scale
|
||||
//!\return width
|
||||
int GetWidth();
|
||||
@ -176,12 +201,18 @@ class GuiElement
|
||||
//!Checks whether or not the element is clickable
|
||||
//!\return true if clickable, false otherwise
|
||||
bool IsClickable();
|
||||
//!Checks whether or not the element is draggable
|
||||
//!\return true if draggable, false otherwise
|
||||
bool IsDraggable();
|
||||
//!Sets whether or not the element is selectable
|
||||
//!\param s Selectable
|
||||
void SetSelectable(bool s);
|
||||
//!Sets whether or not the element is clickable
|
||||
//!\param c Clickable
|
||||
void SetClickable(bool c);
|
||||
//!Sets whether or not the element is draggable
|
||||
//!\param c Draggable
|
||||
void SetDraggable(bool d);
|
||||
//!Gets the element's current state
|
||||
//!\return state
|
||||
int GetState();
|
||||
@ -274,6 +305,10 @@ class GuiElement
|
||||
int height; //!< Element height
|
||||
int xoffset; //!< Element X offset
|
||||
int yoffset; //!< Element Y offset
|
||||
int ymin; //!< Element's min Y offset allowed
|
||||
int ymax; //!< Element's max Y offset allowed
|
||||
int xmin; //!< Element's min X offset allowed
|
||||
int xmax; //!< Element's max X offset allowed
|
||||
int xoffsetDyn; //!< Element X offset, dynamic (added to xoffset value for animation effects)
|
||||
int yoffsetDyn; //!< Element Y offset, dynamic (added to yoffset value for animation effects)
|
||||
int alpha; //!< Element alpha value (0-255)
|
||||
@ -290,8 +325,10 @@ class GuiElement
|
||||
int alignmentHor; //!< Horizontal element alignment, respective to parent element (LEFT, RIGHT, CENTRE)
|
||||
int alignmentVert; //!< Horizontal element alignment, respective to parent element (TOP, BOTTOM, MIDDLE)
|
||||
int state; //!< Element state (DEFAULT, SELECTED, CLICKED, DISABLED)
|
||||
int stateChan; //!< Which controller channel is responsible for the last change in state
|
||||
bool selectable; //!< Whether or not this element selectable (can change to SELECTED state)
|
||||
bool clickable; //!< Whether or not this element is clickable (can change to CLICKED state)
|
||||
bool draggable; //!< Whether or not this element is draggable (can change to HELD state)
|
||||
GuiTrigger * trigger[2]; //!< GuiTriggers (input actions) that this element responds to
|
||||
GuiElement * parentElement; //!< Parent element
|
||||
UpdateCallback updateCB; //!< Callback function to call when this element is updated
|
||||
@ -619,6 +656,7 @@ class GuiFileBrowser : public GuiElement
|
||||
GuiSound * btnSoundOver;
|
||||
GuiSound * btnSoundClick;
|
||||
GuiTrigger * trigA;
|
||||
GuiTrigger * trigHeldA;
|
||||
};
|
||||
|
||||
typedef struct _optionlist {
|
||||
|
@ -1,8 +1,7 @@
|
||||
/****************************************************************************
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* libwiigui
|
||||
*
|
||||
* Tantric February 2009
|
||||
* Tantric 2009
|
||||
*
|
||||
* gui_button.cpp
|
||||
*
|
||||
@ -116,19 +115,19 @@ void GuiButton::Draw()
|
||||
return;
|
||||
|
||||
// draw image
|
||||
if(state == STATE_SELECTED && imageOver)
|
||||
if((state == STATE_SELECTED || state == STATE_HELD) && imageOver)
|
||||
imageOver->Draw();
|
||||
else if(image)
|
||||
image->Draw();
|
||||
// draw icon
|
||||
if(state == STATE_SELECTED && iconOver)
|
||||
if((state == STATE_SELECTED || state == STATE_HELD) && iconOver)
|
||||
iconOver->Draw();
|
||||
else if(icon)
|
||||
icon->Draw();
|
||||
// draw text
|
||||
for(int i=0; i<3; i++)
|
||||
{
|
||||
if(state == STATE_SELECTED && labelOver[i])
|
||||
if((state == STATE_SELECTED || state == STATE_HELD) && labelOver[i])
|
||||
labelOver[i]->Draw();
|
||||
else if(label[i])
|
||||
label[i]->Draw();
|
||||
@ -227,6 +226,45 @@ void GuiButton::Update(GuiTrigger * t)
|
||||
}
|
||||
}
|
||||
|
||||
if(this->IsDraggable())
|
||||
{
|
||||
bool held = false;
|
||||
|
||||
for(int i=0; i<2; i++)
|
||||
{
|
||||
if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan))
|
||||
{
|
||||
// higher 16 bits only (wiimote)
|
||||
s32 wm_btns = t->wpad.btns_h << 16;
|
||||
s32 wm_btns_trig = trigger[i]->wpad.btns_h << 16;
|
||||
|
||||
// lower 16 bits only (classic controller)
|
||||
s32 cc_btns = t->wpad.btns_h >> 16;
|
||||
s32 cc_btns_trig = trigger[i]->wpad.btns_h >> 16;
|
||||
|
||||
if(
|
||||
(t->wpad.btns_h > 0 &&
|
||||
wm_btns == wm_btns_trig ||
|
||||
(cc_btns == cc_btns_trig && t->wpad.exp.type == EXP_CLASSIC)) ||
|
||||
(t->pad.btns_h == trigger[i]->pad.btns_h && t->pad.btns_h > 0))
|
||||
{
|
||||
if(trigger[i]->type == TRIGGER_HELD)
|
||||
held = true;
|
||||
}
|
||||
|
||||
if(!held && state == STATE_HELD && stateChan == t->chan)
|
||||
{
|
||||
state = STATE_DEFAULT;
|
||||
}
|
||||
else if(held && state == STATE_SELECTED)
|
||||
{
|
||||
state = STATE_HELD;
|
||||
stateChan = t->chan; // record which controller is holding the button
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(updateCB)
|
||||
updateCB(this);
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
/****************************************************************************
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* libwiigui
|
||||
*
|
||||
* Tantric February 2009
|
||||
* Tantric 2009
|
||||
*
|
||||
* gui_element.cpp
|
||||
*
|
||||
@ -18,17 +17,23 @@ GuiElement::GuiElement()
|
||||
{
|
||||
xoffset = 0;
|
||||
yoffset = 0;
|
||||
xmin = 0;
|
||||
xmax = 0;
|
||||
ymin = 0;
|
||||
ymax = 0;
|
||||
width = 0;
|
||||
height = 0;
|
||||
alpha = 255;
|
||||
scale = 1;
|
||||
state = STATE_DEFAULT;
|
||||
stateChan = -1;
|
||||
trigger[0] = NULL;
|
||||
trigger[1] = NULL;
|
||||
parentElement = NULL;
|
||||
rumble = true;
|
||||
selectable = false;
|
||||
clickable = false;
|
||||
draggable = false;
|
||||
visible = true;
|
||||
focus = -1; // cannot be focused
|
||||
updateCB = NULL;
|
||||
@ -129,6 +134,46 @@ int GuiElement::GetTop()
|
||||
return y + yoffset;
|
||||
}
|
||||
|
||||
void GuiElement::SetMinX(int x)
|
||||
{
|
||||
xmin = x;
|
||||
}
|
||||
|
||||
int GuiElement::GetMinX()
|
||||
{
|
||||
return xmin;
|
||||
}
|
||||
|
||||
void GuiElement::SetMaxX(int x)
|
||||
{
|
||||
xmax = x;
|
||||
}
|
||||
|
||||
int GuiElement::GetMaxX()
|
||||
{
|
||||
return xmax;
|
||||
}
|
||||
|
||||
void GuiElement::SetMinY(int y)
|
||||
{
|
||||
ymin = y;
|
||||
}
|
||||
|
||||
int GuiElement::GetMinY()
|
||||
{
|
||||
return ymin;
|
||||
}
|
||||
|
||||
void GuiElement::SetMaxY(int y)
|
||||
{
|
||||
ymax = y;
|
||||
}
|
||||
|
||||
int GuiElement::GetMaxY()
|
||||
{
|
||||
return ymax;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of the GuiElement.
|
||||
* @see SetWidth()
|
||||
@ -244,6 +289,11 @@ void GuiElement::SetSelectable(bool s)
|
||||
selectable = s;
|
||||
}
|
||||
|
||||
void GuiElement::SetDraggable(bool d)
|
||||
{
|
||||
draggable = d;
|
||||
}
|
||||
|
||||
bool GuiElement::IsSelectable()
|
||||
{
|
||||
if(state == STATE_DISABLED || state == STATE_CLICKED)
|
||||
@ -254,12 +304,22 @@ bool GuiElement::IsSelectable()
|
||||
|
||||
bool GuiElement::IsClickable()
|
||||
{
|
||||
if(state == STATE_DISABLED || state == STATE_CLICKED)
|
||||
if(state == STATE_DISABLED ||
|
||||
state == STATE_CLICKED ||
|
||||
state == STATE_HELD)
|
||||
return false;
|
||||
else
|
||||
return clickable;
|
||||
}
|
||||
|
||||
bool GuiElement::IsDraggable()
|
||||
{
|
||||
if(state == STATE_DISABLED)
|
||||
return false;
|
||||
else
|
||||
return draggable;
|
||||
}
|
||||
|
||||
void GuiElement::SetFocus(int f)
|
||||
{
|
||||
focus = f;
|
||||
|
@ -1,8 +1,7 @@
|
||||
/****************************************************************************
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* libwiigui
|
||||
*
|
||||
* Tantric February 2009
|
||||
* Tantric 2009
|
||||
*
|
||||
* gui_filebrowser.cpp
|
||||
*
|
||||
@ -30,6 +29,12 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
|
||||
else
|
||||
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
||||
|
||||
trigHeldA = new GuiTrigger;
|
||||
if(GCSettings.WiimoteOrientation)
|
||||
trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_2 | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
||||
else
|
||||
trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
||||
|
||||
btnSoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM);
|
||||
btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM);
|
||||
|
||||
@ -85,7 +90,12 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
|
||||
scrollbarBoxBtn->SetImage(scrollbarBoxImg);
|
||||
scrollbarBoxBtn->SetImageOver(scrollbarBoxOverImg);
|
||||
scrollbarBoxBtn->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
||||
scrollbarBoxBtn->SetMinY(0);
|
||||
scrollbarBoxBtn->SetMaxY(304);
|
||||
scrollbarBoxBtn->SetSelectable(false);
|
||||
scrollbarBoxBtn->SetClickable(false);
|
||||
scrollbarBoxBtn->SetDraggable(true);
|
||||
scrollbarBoxBtn->SetTrigger(trigHeldA);
|
||||
|
||||
for(int i=0; i<PAGESIZE; i++)
|
||||
{
|
||||
@ -203,14 +213,45 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
if(state == STATE_DISABLED || !t)
|
||||
return;
|
||||
|
||||
int position;
|
||||
|
||||
// update the location of the scroll box based on the position in the file list
|
||||
int position = 136*(browser.pageIndex + selectedItem) / browser.numEntries;
|
||||
position = 136*(browser.pageIndex + selectedItem) / browser.numEntries;
|
||||
scrollbarBoxBtn->SetPosition(0,position+36);
|
||||
|
||||
arrowUpBtn->Update(t);
|
||||
arrowDownBtn->Update(t);
|
||||
scrollbarBoxBtn->Update(t);
|
||||
|
||||
if(scrollbarBoxBtn->GetState() == STATE_HELD)
|
||||
{
|
||||
// move the file listing to respond to wiimote cursor movement
|
||||
if(t->wpad.ir.valid)
|
||||
{
|
||||
scrollbarBoxBtn->SetPosition(0,0);
|
||||
position = t->wpad.ir.y - 60 - scrollbarBoxBtn->GetTop();
|
||||
|
||||
if(position > scrollbarBoxBtn->GetMinY() &&
|
||||
position < scrollbarBoxBtn->GetMaxY())
|
||||
{
|
||||
scrollbarBoxBtn->SetPosition(0, position);
|
||||
browser.pageIndex = (position * browser.numEntries)/136.0 - selectedItem;
|
||||
|
||||
if(browser.pageIndex <= 0)
|
||||
{
|
||||
browser.pageIndex = 0;
|
||||
selectedItem = 0;
|
||||
}
|
||||
else if(browser.pageIndex+PAGESIZE >= browser.numEntries)
|
||||
{
|
||||
browser.pageIndex = browser.numEntries-PAGESIZE;
|
||||
selectedItem = PAGESIZE-1;
|
||||
}
|
||||
listChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pad/joystick navigation
|
||||
if(!focus)
|
||||
{
|
||||
|
@ -1,8 +1,7 @@
|
||||
/****************************************************************************
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* libwiigui
|
||||
*
|
||||
* Tantric February 2009
|
||||
* Tantric 2009
|
||||
*
|
||||
* gui_image.cpp
|
||||
*
|
||||
|
@ -1,8 +1,7 @@
|
||||
/****************************************************************************
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* libwiigui
|
||||
*
|
||||
* Tantric February 2009
|
||||
* Tantric 2009
|
||||
*
|
||||
* gui_imagedata.cpp
|
||||
*
|
||||
|
@ -1,8 +1,7 @@
|
||||
/****************************************************************************
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* libwiigui
|
||||
*
|
||||
* Tantric February 2009
|
||||
* Tantric 2009
|
||||
*
|
||||
* gui_keyboard.cpp
|
||||
*
|
||||
|
@ -1,8 +1,7 @@
|
||||
/****************************************************************************
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* libwiigui
|
||||
*
|
||||
* Tantric February 2009
|
||||
* Tantric 2009
|
||||
*
|
||||
* gui_optionbrowser.cpp
|
||||
*
|
||||
|
@ -1,8 +1,7 @@
|
||||
/****************************************************************************
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* libwiigui
|
||||
*
|
||||
* Tantric February 2009
|
||||
* Tantric 2009
|
||||
*
|
||||
* gui_savebrowser.cpp
|
||||
*
|
||||
|
@ -1,8 +1,7 @@
|
||||
/****************************************************************************
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* libwiigui
|
||||
*
|
||||
* Tantric February 2009
|
||||
* Tantric 2009
|
||||
*
|
||||
* gui_sound.cpp
|
||||
*
|
||||
|
@ -1,8 +1,7 @@
|
||||
/****************************************************************************
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* libwiigui
|
||||
*
|
||||
* Tantric February 2009
|
||||
* Tantric 2009
|
||||
*
|
||||
* gui_text.cpp
|
||||
*
|
||||
|
@ -1,8 +1,7 @@
|
||||
/****************************************************************************
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* libwiigui
|
||||
*
|
||||
* Tantric February 2009
|
||||
* Tantric 2009
|
||||
*
|
||||
* gui_trigger.cpp
|
||||
*
|
||||
@ -43,6 +42,19 @@ void GuiTrigger::SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
|
||||
pad.btns_d = gcbtns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a held trigger. Requires:
|
||||
* - Element is selected
|
||||
* - Trigger button is pressed and held
|
||||
*/
|
||||
void GuiTrigger::SetHeldTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
|
||||
{
|
||||
type = TRIGGER_HELD;
|
||||
chan = ch;
|
||||
wpad.btns_h = wiibtns;
|
||||
pad.btns_h = gcbtns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a button trigger. Requires:
|
||||
* - Trigger button is pressed
|
||||
|
@ -1,8 +1,7 @@
|
||||
/****************************************************************************
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* libwiigui
|
||||
*
|
||||
* Tantric February 2009
|
||||
* Tantric 2009
|
||||
*
|
||||
* gui_window.cpp
|
||||
*
|
||||
|
@ -24,6 +24,7 @@
|
||||
enum
|
||||
{
|
||||
TRIGGER_SIMPLE,
|
||||
TRIGGER_HELD,
|
||||
TRIGGER_BUTTON_ONLY,
|
||||
TRIGGER_BUTTON_ONLY_IN_FOCUS
|
||||
};
|
||||
@ -46,6 +47,7 @@ class GuiTrigger
|
||||
GuiTrigger();
|
||||
~GuiTrigger();
|
||||
void SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
|
||||
void SetHeldTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
|
||||
void SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
|
||||
void SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
|
||||
s8 WPAD_Stick(u8 right, int axis);
|
||||
|
Loading…
Reference in New Issue
Block a user