Modified files for SDL2.

This commit is contained in:
LuisAntonRebollo 2015-01-18 22:52:29 +01:00
parent 33a0579735
commit 475f218bcd
33 changed files with 436 additions and 136 deletions

View file

@ -427,7 +427,7 @@ extern "C" {
PlatformWindowManager::get()->getFirstWindow()->setSize(Point2I(width,height)); PlatformWindowManager::get()->getFirstWindow()->setSize(Point2I(width,height));
} }
#ifdef TORQUE_OS_WIN #if defined(TORQUE_OS_WIN) && !defined(TORQUE_SDL)
// retrieve the hwnd of our render window // retrieve the hwnd of our render window
void* torque_gethwnd() void* torque_gethwnd()
{ {

View file

@ -332,10 +332,8 @@ void GFXPCD3D9Device::init( const GFXVideoMode &mode, PlatformWindow *window /*
initD3DXFnTable(); initD3DXFnTable();
Win32Window *win = dynamic_cast<Win32Window*>( window ); HWND winHwnd = (HWND)window->getSystemWindow( PlatformWindow::WindowSystem_Windows );
AssertISV( win, "GFXD3D9Device::init - got a non Win32Window window passed in! Did DX go crossplatform?" ); AssertISV(winHwnd, "GFXPCD3D9WindowTarget::initPresentationParams() - no HWND");
HWND winHwnd = win->getHWND();
// Create D3D Presentation params // Create D3D Presentation params
D3DPRESENT_PARAMETERS d3dpp = setupPresentParams( mode, winHwnd ); D3DPRESENT_PARAMETERS d3dpp = setupPresentParams( mode, winHwnd );
@ -1021,10 +1019,6 @@ bool GFXPCD3D9Device::beginSceneInternal()
GFXWindowTarget * GFXPCD3D9Device::allocWindowTarget( PlatformWindow *window ) GFXWindowTarget * GFXPCD3D9Device::allocWindowTarget( PlatformWindow *window )
{ {
AssertFatal(window,"GFXD3D9Device::allocWindowTarget - no window provided!"); AssertFatal(window,"GFXD3D9Device::allocWindowTarget - no window provided!");
#ifndef TORQUE_OS_XENON
AssertFatal(dynamic_cast<Win32Window*>(window),
"GFXD3D9Device::allocWindowTarget - only works with Win32Windows!");
#endif
// Set up a new window target... // Set up a new window target...
GFXPCD3D9WindowTarget *gdwt = new GFXPCD3D9WindowTarget(); GFXPCD3D9WindowTarget *gdwt = new GFXPCD3D9WindowTarget();

View file

@ -372,10 +372,8 @@ void GFXPCD3D9WindowTarget::initPresentationParams()
"GFXPCD3D9WindowTarget::initPresentationParams - Cannot go fullscreen with secondary window!"); "GFXPCD3D9WindowTarget::initPresentationParams - Cannot go fullscreen with secondary window!");
} }
Win32Window *win = dynamic_cast<Win32Window*>(mWindow); HWND hwnd = (HWND)mWindow->getSystemWindow( PlatformWindow::WindowSystem_Windows );
AssertISV(win, "GFXPCD3D9WindowTarget::initPresentationParams() - got a non Win32Window window passed in! Did DX go crossplatform?"); AssertISV(hwnd, "GFXPCD3D9WindowTarget::initPresentationParams() - no HWND");
HWND hwnd = win->getHWND();
// At some point, this will become GFXPCD3D9WindowTarget like trunk has, // At some point, this will become GFXPCD3D9WindowTarget like trunk has,
// so this cast isn't as bad as it looks. ;) BTR // so this cast isn't as bad as it looks. ;) BTR

View file

@ -30,6 +30,7 @@
#include "gfx/gfxDrawUtil.h" #include "gfx/gfxDrawUtil.h"
#include "gui/core/guiTypes.h" #include "gui/core/guiTypes.h"
#include "gui/core/guiControl.h" #include "gui/core/guiControl.h"
#include "gui/editor/guiMenuBar.h"
#include "console/consoleTypes.h" #include "console/consoleTypes.h"
#include "gfx/screenshot.h" #include "gfx/screenshot.h"
#include "gfx/video/videoCapture.h" #include "gfx/video/videoCapture.h"
@ -283,6 +284,8 @@ bool GuiCanvas::onAdd()
mLastPurchaseHideTime = 0; mLastPurchaseHideTime = 0;
#endif #endif
Sim::findObject("PlatformGenericMenubar", mMenuBarCtrl);
return parentRet; return parentRet;
} }
@ -302,6 +305,34 @@ void GuiCanvas::onRemove()
Parent::onRemove(); Parent::onRemove();
} }
void GuiCanvas::setMenuBar(SimObject *obj)
{
GuiControl *oldMenuBar = mMenuBarCtrl;
mMenuBarCtrl = dynamic_cast<GuiControl*>(obj);
//remove old menubar
if( oldMenuBar )
Parent::removeObject( oldMenuBar );
// set new menubar
if( mMenuBarCtrl )
Parent::addObject(mMenuBarCtrl);
// update window accelerator keys
if( oldMenuBar != mMenuBarCtrl )
{
StringTableEntry ste = StringTable->insert("menubar");
GuiMenuBar* menu = NULL;
menu = !oldMenuBar ? NULL : dynamic_cast<GuiMenuBar*>(oldMenuBar->findObjectByInternalName( ste, true));
if( menu )
menu->removeWindowAcceleratorMap( *getPlatformWindow()->getInputGenerator() );
menu = !mMenuBarCtrl ? NULL : dynamic_cast<GuiMenuBar*>(mMenuBarCtrl->findObjectByInternalName( ste, true));
if( menu )
menu->buildWindowAcceleratorMap( *getPlatformWindow()->getInputGenerator() );
}
}
void GuiCanvas::setWindowTitle(const char *newTitle) void GuiCanvas::setWindowTitle(const char *newTitle)
{ {
if (mPlatformWindow) if (mPlatformWindow)
@ -1023,7 +1054,7 @@ void GuiCanvas::rootMouseDown(const GuiEvent &event)
{ {
i--; i--;
GuiControl *ctrl = static_cast<GuiControl *>(*i); GuiControl *ctrl = static_cast<GuiControl *>(*i);
GuiControl *controlHit = ctrl->findHitControl(event.mousePoint); GuiControl *controlHit = ctrl->findHitControl( event.mousePoint - ctrl->getPosition() );
//see if the controlHit is a modeless dialog... //see if the controlHit is a modeless dialog...
if( !controlHit->getControlProfile()->mModal ) if( !controlHit->getControlProfile()->mModal )
@ -1293,6 +1324,9 @@ void GuiCanvas::setContentControl(GuiControl *gui)
Sim::getGuiGroup()->addObject( ctrl ); Sim::getGuiGroup()->addObject( ctrl );
} }
// set current menu bar
setMenuBar( mMenuBarCtrl );
// lose the first responder from the old GUI // lose the first responder from the old GUI
GuiControl* responder = gui->findFirstTabable(); GuiControl* responder = gui->findFirstTabable();
if(responder) if(responder)
@ -1556,10 +1590,27 @@ void GuiCanvas::maintainSizing()
GuiControl *ctrl = static_cast<GuiControl*>(*i); GuiControl *ctrl = static_cast<GuiControl*>(*i);
Point2I ext = ctrl->getExtent(); Point2I ext = ctrl->getExtent();
Point2I pos = ctrl->getPosition(); Point2I pos = ctrl->getPosition();
Point2I newExt = screenRect.extent;
Point2I newPos = screenRect.point;
if(pos != screenRect.point || ext != screenRect.extent) // if menubar is active displace content gui control
if( mMenuBarCtrl && (ctrl == getContentControl()) )
{
const SimObject *menu = mMenuBarCtrl->findObjectByInternalName( StringTable->insert("menubar"), true);
if( !menu )
continue;
AssertFatal( dynamic_cast<const GuiControl*>(menu), "");
const U32 yOffset = static_cast<const GuiControl*>(menu)->getExtent().y;
newPos.y += yOffset;
newExt.y -= yOffset;
}
if(pos != newPos || ext != newExt)
{ {
ctrl->resize(screenRect.point, screenRect.extent); ctrl->resize(newPos, newExt);
resetUpdateRegions(); resetUpdateRegions();
} }
} }
@ -2273,7 +2324,7 @@ DefineEngineFunction(excludeOtherInstance, bool, (const char* appIdentifer),,
"@ingroup GuiCore") "@ingroup GuiCore")
{ {
// mac/360 can only run one instance in general. // mac/360 can only run one instance in general.
#if !defined(TORQUE_OS_MAC) && !defined(TORQUE_OS_XENON) && !defined(TORQUE_DEBUG) #if !defined(TORQUE_OS_MAC) && !defined(TORQUE_OS_XENON) && !defined(TORQUE_DEBUG) && !defined(TORQUE_OS_LINUX)
return Platform::excludeOtherInstances(appIdentifer); return Platform::excludeOtherInstances(appIdentifer);
#else #else
// We can just return true if we get here. // We can just return true if we get here.
@ -2580,6 +2631,14 @@ DefineConsoleMethod( GuiCanvas, setFocus, void, (), , "() - Claim OS input focus
window->setFocus(); window->setFocus();
} }
DefineEngineMethod( GuiCanvas, setMenuBar, void, ( GuiControl* menu ),,
"Translate a coordinate from canvas window-space to screen-space.\n"
"@param coordinate The coordinate in window-space.\n"
"@return The given coordinate translated to screen-space." )
{
return object->setMenuBar( menu );
}
DefineConsoleMethod( GuiCanvas, setVideoMode, void, DefineConsoleMethod( GuiCanvas, setVideoMode, void,
(U32 width, U32 height, bool fullscreen, U32 bitDepth, U32 refreshRate, U32 antialiasLevel), (U32 width, U32 height, bool fullscreen, U32 bitDepth, U32 refreshRate, U32 antialiasLevel),
( false, 0, 0, 0), ( false, 0, 0, 0),

View file

@ -190,6 +190,8 @@ protected:
void checkLockMouseMove( const GuiEvent& event ); void checkLockMouseMove( const GuiEvent& event );
GuiControl *mMenuBarCtrl;
public: public:
DECLARE_CONOBJECT(GuiCanvas); DECLARE_CONOBJECT(GuiCanvas);
DECLARE_CATEGORY( "Gui Core" ); DECLARE_CATEGORY( "Gui Core" );
@ -200,6 +202,8 @@ public:
virtual bool onAdd(); virtual bool onAdd();
virtual void onRemove(); virtual void onRemove();
void setMenuBar(SimObject *obj);
static void initPersistFields(); static void initPersistFields();
/// @name Rendering methods /// @name Rendering methods

View file

@ -215,8 +215,8 @@ DefineEngineMethod(GuiMenuBar, addMenu, void, (const char* menuText, S32 menuId)
object->addMenu(menuText, menuId); object->addMenu(menuText, menuId);
} }
DefineEngineMethod(GuiMenuBar, addMenuItem, void, (const char* targetMenu, const char* menuItemText, S32 menuItemId, const char* accelerator, int checkGroup), DefineEngineMethod(GuiMenuBar, addMenuItem, void, (const char* targetMenu, const char* menuItemText, S32 menuItemId, const char* accelerator, int checkGroup, const char *cmd),
("","",0,"",-1), ("","",0,NULL,-1,""),
"@brief Adds a menu item to the specified menu. The menu argument can be either the text of a menu or its id.\n\n" "@brief Adds a menu item to the specified menu. The menu argument can be either the text of a menu or its id.\n\n"
"@param menu Menu name or menu Id to add the new item to.\n" "@param menu Menu name or menu Id to add the new item to.\n"
"@param menuItemText Text for the new menu item.\n" "@param menuItemText Text for the new menu item.\n"
@ -250,7 +250,7 @@ DefineEngineMethod(GuiMenuBar, addMenuItem, void, (const char* targetMenu, const
Con::errorf("Cannot find menu %s for addMenuItem.", targetMenu); Con::errorf("Cannot find menu %s for addMenuItem.", targetMenu);
return; return;
} }
object->addMenuItem(menu, menuItemText, menuItemId, accelerator != NULL ? accelerator : "", checkGroup == -1 ? -1 : checkGroup); object->addMenuItem(menu, menuItemText, menuItemId, accelerator != NULL ? accelerator : "", checkGroup == -1 ? -1 : checkGroup, cmd);
} }
DefineEngineMethod(GuiMenuBar, setMenuItemEnable, void, (const char* menuTarget, const char* menuItemTarget, bool enabled),, DefineEngineMethod(GuiMenuBar, setMenuItemEnable, void, (const char* menuTarget, const char* menuItemTarget, bool enabled),,
@ -767,7 +767,7 @@ DefineEngineMethod(GuiMenuBar, setSubmenuItemChecked, void, (const char* menuTar
if(checked && submenuItem->checkGroup != -1) if(checked && submenuItem->checkGroup != -1)
{ {
// first, uncheck everything in the group: // first, uncheck everything in the group:
for(GuiMenuBar::MenuItem *itemWalk = menuItem->firstSubmenuItem; itemWalk; itemWalk = itemWalk->nextMenuItem) for(GuiMenuBar::MenuItem *itemWalk = menuItem->submenu->firstMenuItem; itemWalk; itemWalk = itemWalk->nextMenuItem)
if(itemWalk->checkGroup == submenuItem->checkGroup && itemWalk->bitmapIndex == object->mCheckmarkBitmapIndex) if(itemWalk->checkGroup == submenuItem->checkGroup && itemWalk->bitmapIndex == object->mCheckmarkBitmapIndex)
itemWalk->bitmapIndex = -1; itemWalk->bitmapIndex = -1;
} }
@ -777,8 +777,7 @@ DefineEngineMethod(GuiMenuBar, setSubmenuItemChecked, void, (const char* menuTar
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// menu management methods // menu management methods
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
GuiMenuBar::Menu* GuiMenuBar::sCreateMenu(const char *menuText, U32 menuId)
void GuiMenuBar::addMenu(const char *menuText, U32 menuId)
{ {
// allocate the menu // allocate the menu
Menu *newMenu = new Menu; Menu *newMenu = new Menu;
@ -792,7 +791,12 @@ void GuiMenuBar::addMenu(const char *menuText, U32 menuId)
newMenu->bitmapIndex = -1; newMenu->bitmapIndex = -1;
newMenu->drawBitmapOnly = false; newMenu->drawBitmapOnly = false;
newMenu->drawBorder = true; newMenu->drawBorder = true;
return newMenu;
}
void GuiMenuBar::addMenu(GuiMenuBar::Menu *newMenu)
{
// add it to the menu list // add it to the menu list
menuBarDirty = true; menuBarDirty = true;
Menu **walk; Menu **walk;
@ -801,6 +805,13 @@ void GuiMenuBar::addMenu(const char *menuText, U32 menuId)
*walk = newMenu; *walk = newMenu;
} }
void GuiMenuBar::addMenu(const char *menuText, U32 menuId)
{
Menu *newMenu = sCreateMenu(menuText, menuId);
addMenu(newMenu);
}
GuiMenuBar::Menu *GuiMenuBar::findMenu(const char *menu) GuiMenuBar::Menu *GuiMenuBar::findMenu(const char *menu)
{ {
if(dIsdigit(menu[0])) if(dIsdigit(menu[0]))
@ -877,7 +888,7 @@ void GuiMenuBar::removeMenuItem(Menu *menu, MenuItem *menuItem)
delete menuItem; delete menuItem;
} }
void GuiMenuBar::addMenuItem(Menu *menu, const char *text, U32 id, const char *accelerator, S32 checkGroup) GuiMenuBar::MenuItem* GuiMenuBar::addMenuItem(Menu *menu, const char *text, U32 id, const char *accelerator, S32 checkGroup, const char *cmd )
{ {
// allocate the new menu item // allocate the new menu item
MenuItem *newMenuItem = new MenuItem; MenuItem *newMenuItem = new MenuItem;
@ -886,6 +897,7 @@ void GuiMenuBar::addMenuItem(Menu *menu, const char *text, U32 id, const char *a
newMenuItem->accelerator = dStrdup(accelerator); newMenuItem->accelerator = dStrdup(accelerator);
else else
newMenuItem->accelerator = NULL; newMenuItem->accelerator = NULL;
newMenuItem->cmd = cmd;
newMenuItem->id = id; newMenuItem->id = id;
newMenuItem->checkGroup = checkGroup; newMenuItem->checkGroup = checkGroup;
newMenuItem->nextMenuItem = NULL; newMenuItem->nextMenuItem = NULL;
@ -896,15 +908,33 @@ void GuiMenuBar::addMenuItem(Menu *menu, const char *text, U32 id, const char *a
// Default to not having a submenu // Default to not having a submenu
newMenuItem->isSubmenu = false; newMenuItem->isSubmenu = false;
newMenuItem->firstSubmenuItem = NULL; newMenuItem->submenu = NULL;
newMenuItem->submenuParentMenu = NULL; newMenuItem->submenuParentMenu = NULL;
// link it into the menu's menu item list // link it into the menu's menu item list
MenuItem **walk = &menu->firstMenuItem; if(menu)
while(*walk) {
walk = &(*walk)->nextMenuItem; MenuItem **walk = &menu->firstMenuItem;
*walk = newMenuItem; while(*walk)
walk = &(*walk)->nextMenuItem;
*walk = newMenuItem;
}
return newMenuItem;
}
GuiMenuBar::MenuItem* GuiMenuBar::addMenuItem(Menu *menu, MenuItem* newMenuItem)
{
// link it into the menu's menu item list
if(menu)
{
MenuItem **walk = &menu->firstMenuItem;
while(*walk)
walk = &(*walk)->nextMenuItem;
*walk = newMenuItem;
}
return newMenuItem;
} }
void GuiMenuBar::clearMenuItems(Menu *menu) void GuiMenuBar::clearMenuItems(Menu *menu)
@ -935,16 +965,9 @@ GuiMenuBar::MenuItem *GuiMenuBar::findSubmenuItem(Menu *menu, const char *menuIt
for(MenuItem *walk = menu->firstMenuItem; walk; walk = walk->nextMenuItem) for(MenuItem *walk = menu->firstMenuItem; walk; walk = walk->nextMenuItem)
if(id == walk->id) if(id == walk->id)
{ {
if(walk->isSubmenu) if(walk->isSubmenu && walk->submenu)
{ {
U32 subid = dAtoi(submenuItem); return GuiMenuBar::findMenuItem(walk->submenu, submenuItem);
for(MenuItem *subwalk = walk->firstSubmenuItem; subwalk; subwalk = subwalk->nextMenuItem)
{
if(subid == walk->id)
{
return subwalk;
}
}
} }
return NULL; return NULL;
} }
@ -956,13 +979,9 @@ GuiMenuBar::MenuItem *GuiMenuBar::findSubmenuItem(Menu *menu, const char *menuIt
for(MenuItem *walk = menu->firstMenuItem; walk; walk = walk->nextMenuItem) for(MenuItem *walk = menu->firstMenuItem; walk; walk = walk->nextMenuItem)
if(!dStricmp(menuItem, walk->text)) if(!dStricmp(menuItem, walk->text))
{ {
if(walk->isSubmenu) if(walk->isSubmenu && walk->submenu)
{ {
for(MenuItem *subwalk = walk->firstSubmenuItem; subwalk; subwalk = subwalk->nextMenuItem) return GuiMenuBar::findMenuItem(walk->submenu, submenuItem);
{
if(!dStricmp(submenuItem, subwalk->text))
return subwalk;
}
} }
return NULL; return NULL;
} }
@ -970,6 +989,14 @@ GuiMenuBar::MenuItem *GuiMenuBar::findSubmenuItem(Menu *menu, const char *menuIt
} }
} }
GuiMenuBar::MenuItem* GuiMenuBar::findSubmenuItem(MenuItem *menuItem, const char *submenuItem)
{
if( !menuItem->isSubmenu )
return NULL;
return GuiMenuBar::findMenuItem( menuItem->submenu, submenuItem );
}
// Add a menuitem to the given submenu // Add a menuitem to the given submenu
void GuiMenuBar::addSubmenuItem(Menu *menu, MenuItem *submenu, const char *text, U32 id, const char *accelerator, S32 checkGroup) void GuiMenuBar::addSubmenuItem(Menu *menu, MenuItem *submenu, const char *text, U32 id, const char *accelerator, S32 checkGroup)
{ {
@ -997,17 +1024,30 @@ void GuiMenuBar::addSubmenuItem(Menu *menu, MenuItem *submenu, const char *text,
// Default to not having a submenu // Default to not having a submenu
newMenuItem->isSubmenu = false; newMenuItem->isSubmenu = false;
newMenuItem->firstSubmenuItem = NULL; newMenuItem->submenu = NULL;
// Point back to the submenu's menu // Point back to the submenu's menu
newMenuItem->submenuParentMenu = menu; newMenuItem->submenuParentMenu = menu;
// link it into the menu's menu item list // link it into the menu's menu item list
MenuItem **walk = &submenu->firstSubmenuItem; MenuItem **walk = &submenu->submenu->firstMenuItem;
while(*walk) while(*walk)
walk = &(*walk)->nextMenuItem; walk = &(*walk)->nextMenuItem;
*walk = newMenuItem; *walk = newMenuItem;
}
void GuiMenuBar::addSubmenuItem(Menu *menu, MenuItem *submenu, MenuItem *newMenuItem )
{
AssertFatal( submenu && newMenuItem, "");
// Point back to the submenu's menu
newMenuItem->submenuParentMenu = menu;
// link it into the menu's menu item list
MenuItem **walk = &submenu->submenu->firstMenuItem;
while(*walk)
walk = &(*walk)->nextMenuItem;
*walk = newMenuItem;
} }
// Remove a submenu item // Remove a submenu item
@ -1020,17 +1060,7 @@ void GuiMenuBar::removeSubmenuItem(MenuItem *menuItem, MenuItem *submenuItem)
return; return;
} }
for(MenuItem **subwalk = &menuItem->firstSubmenuItem; *subwalk; subwalk = &(*subwalk)->nextMenuItem) GuiMenuBar::removeMenuItem(menuItem->submenu, submenuItem);
{
if(*subwalk == submenuItem)
{
*subwalk = submenuItem->nextMenuItem;
break;
}
}
dFree(submenuItem->text);
dFree(submenuItem->accelerator);
delete submenuItem;
} }
// Clear all menuitems from a submenu // Clear all menuitems from a submenu
@ -1043,8 +1073,8 @@ void GuiMenuBar::clearSubmenuItems(MenuItem *menuitem)
return; return;
} }
while(menuitem->firstSubmenuItem) while(menuitem->submenu->firstMenuItem)
removeSubmenuItem(menuitem, menuitem->firstSubmenuItem); removeSubmenuItem(menuitem, menuitem->submenu->firstMenuItem);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -1317,9 +1347,8 @@ void GuiMenuBar::onRender(Point2I offset, const RectI &updateRect)
renderChildControls( offset, updateRect ); renderChildControls( offset, updateRect );
} }
void GuiMenuBar::buildAcceleratorMap() void GuiMenuBar::buildWindowAcceleratorMap( WindowInputGenerator &inputGenerator )
{ {
Parent::buildAcceleratorMap();
// ok, accelerator map is cleared... // ok, accelerator map is cleared...
// add all our keys: // add all our keys:
mCurAcceleratorIndex = 1; mCurAcceleratorIndex = 1;
@ -1334,18 +1363,22 @@ void GuiMenuBar::buildAcceleratorMap()
continue; continue;
} }
EventDescriptor accelEvent; EventDescriptor accelEvent;
ActionMap::createEventDescriptor(item->accelerator, &accelEvent); ActionMap::createEventDescriptor(item->accelerator, &accelEvent);
//now we have a modifier, and a key, add them to the canvas //now we have a modifier, and a key, add them to the canvas
GuiCanvas *root = getRoot(); inputGenerator.addAcceleratorKey( this, item->cmd, accelEvent.eventCode, accelEvent.flags);
if (root)
root->addAcceleratorKey(this, mCurAcceleratorIndex, accelEvent.eventCode, accelEvent.flags);
item->acceleratorIndex = mCurAcceleratorIndex; item->acceleratorIndex = mCurAcceleratorIndex;
mCurAcceleratorIndex++; mCurAcceleratorIndex++;
} }
} }
} }
void GuiMenuBar::removeWindowAcceleratorMap( WindowInputGenerator &inputGenerator )
{
inputGenerator.removeAcceleratorKeys( this );
}
void GuiMenuBar::acceleratorKeyPress(U32 index) void GuiMenuBar::acceleratorKeyPress(U32 index)
{ {
// loop through all the menus // loop through all the menus
@ -1617,7 +1650,7 @@ void GuiMenuBar::highlightedMenuItem(S32 selectionIndex, RectI bounds, Point2I c
if(list->isSubmenu) if(list->isSubmenu)
{ {
// If there are submenu items, then open the submenu // If there are submenu items, then open the submenu
if(list->firstSubmenuItem) if(list->submenu->firstMenuItem)
{ {
mouseOverSubmenu = list; mouseOverSubmenu = list;
onSubmenuAction(selstore, bounds, cellSize); onSubmenuAction(selstore, bounds, cellSize);
@ -1752,7 +1785,7 @@ void GuiMenuBar::onSubmenuAction(S32 selectionIndex, RectI bounds, Point2I cellS
// first, call the script callback for menu selection: // first, call the script callback for menu selection:
onSubmenuSelect_callback(Con::getIntArg(mouseOverSubmenu->id), mouseOverSubmenu->text); onSubmenuSelect_callback(Con::getIntArg(mouseOverSubmenu->id), mouseOverSubmenu->text);
MenuItem *visWalk = mouseOverSubmenu->firstSubmenuItem; MenuItem *visWalk = mouseOverSubmenu->submenu->firstMenuItem;
while(visWalk) while(visWalk)
{ {
if(visWalk->visible) if(visWalk->visible)
@ -1780,7 +1813,7 @@ void GuiMenuBar::onSubmenuAction(S32 selectionIndex, RectI bounds, Point2I cellS
GFont *font = mProfile->mFont; GFont *font = mProfile->mFont;
for(MenuItem *walk = mouseOverSubmenu->firstSubmenuItem; walk; walk = walk->nextMenuItem) for(MenuItem *walk = mouseOverSubmenu->submenu->firstMenuItem; walk; walk = walk->nextMenuItem)
{ {
if(!walk->visible) if(!walk->visible)
continue; continue;
@ -1803,7 +1836,7 @@ void GuiMenuBar::onSubmenuAction(S32 selectionIndex, RectI bounds, Point2I cellS
U32 entryCount = 0; U32 entryCount = 0;
for(MenuItem *walk = mouseOverSubmenu->firstSubmenuItem; walk; walk = walk->nextMenuItem) for(MenuItem *walk = mouseOverSubmenu->submenu->firstMenuItem; walk; walk = walk->nextMenuItem)
{ {
if(!walk->visible) if(!walk->visible)
continue; continue;
@ -1885,7 +1918,7 @@ void GuiMenuBar::closeSubmenu()
MenuItem *list = NULL; MenuItem *list = NULL;
if(mouseOverSubmenu) if(mouseOverSubmenu)
{ {
list = mouseOverSubmenu->firstSubmenuItem; list = mouseOverSubmenu->submenu->firstMenuItem;
while(selectionIndex && list) while(selectionIndex && list)
{ {

View file

@ -32,6 +32,7 @@
class GuiMenuBar; class GuiMenuBar;
class GuiMenuTextListCtrl; class GuiMenuTextListCtrl;
class WindowInputGenerator;
class GuiMenuBackgroundCtrl : public GuiControl class GuiMenuBackgroundCtrl : public GuiControl
{ {
@ -105,9 +106,10 @@ public:
MenuItem *nextMenuItem; // next menu item in the linked list MenuItem *nextMenuItem; // next menu item in the linked list
bool isSubmenu; // This menu item has a submenu that will be displayed bool isSubmenu; // This menu item has a submenu that will be displayed
MenuItem *firstSubmenuItem; // The first menu item in the submenu
Menu* submenuParentMenu; // For a submenu, this is the parent menu Menu* submenuParentMenu; // For a submenu, this is the parent menu
Menu* submenu;
String cmd;
}; };
struct Menu struct Menu
@ -161,21 +163,25 @@ public:
// internal menu handling functions // internal menu handling functions
// these are used by the script manipulation functions to add/remove/change menu items // these are used by the script manipulation functions to add/remove/change menu items
static Menu* sCreateMenu(const char *menuText, U32 menuId);
void addMenu(Menu *menu);
void addMenu(const char *menuText, U32 menuId); void addMenu(const char *menuText, U32 menuId);
Menu *findMenu(const char *menu); // takes either a menu text or a string id Menu *findMenu(const char *menu); // takes either a menu text or a string id
MenuItem *findMenuItem(Menu *menu, const char *menuItem); // takes either a menu text or a string id static MenuItem *findMenuItem(Menu *menu, const char *menuItem); // takes either a menu text or a string id
void removeMenu(Menu *menu); void removeMenu(Menu *menu);
void removeMenuItem(Menu *menu, MenuItem *menuItem); static void removeMenuItem(Menu *menu, MenuItem *menuItem);
void addMenuItem(Menu *menu, const char *text, U32 id, const char *accelerator, S32 checkGroup); static MenuItem* addMenuItem(Menu *menu, const char *text, U32 id, const char *accelerator, S32 checkGroup, const char *cmd);
void clearMenuItems(Menu *menu); static MenuItem* addMenuItem(Menu *menu, MenuItem *menuItem);
static void clearMenuItems(Menu *menu);
void clearMenus(); void clearMenus();
// Methods to deal with submenus // Methods to deal with submenus
MenuItem* findSubmenuItem(Menu *menu, const char *menuItem, const char *submenuItem); static MenuItem* findSubmenuItem(Menu *menu, const char *menuItem, const char *submenuItem);
void addSubmenuItem(Menu *menu, MenuItem *submenu, const char *text, U32 id, const char *accelerator, S32 checkGroup); static MenuItem* findSubmenuItem(MenuItem *menuItem, const char *submenuItem);
void removeSubmenuItem(MenuItem *menuItem, MenuItem *submenuItem); static void addSubmenuItem(Menu *menu, MenuItem *submenu, const char *text, U32 id, const char *accelerator, S32 checkGroup);
void clearSubmenuItems(MenuItem *menuitem); static void addSubmenuItem(Menu *menu, MenuItem *submenu, MenuItem *newMenuItem );
static void removeSubmenuItem(MenuItem *menuItem, MenuItem *submenuItem);
static void clearSubmenuItems(MenuItem *menuitem);
void onSubmenuAction(S32 selectionIndex, RectI bounds, Point2I cellSize); void onSubmenuAction(S32 selectionIndex, RectI bounds, Point2I cellSize);
void closeSubmenu(); void closeSubmenu();
void checkSubmenuMouseMove(const GuiEvent &event); void checkSubmenuMouseMove(const GuiEvent &event);
@ -202,10 +208,11 @@ public:
void onAction(); void onAction();
void closeMenu(); void closeMenu();
void buildAcceleratorMap(); void buildWindowAcceleratorMap( WindowInputGenerator &inputGenerator );
void removeWindowAcceleratorMap( WindowInputGenerator &inputGenerator );
void acceleratorKeyPress(U32 index); void acceleratorKeyPress(U32 index);
void menuItemSelected(Menu *menu, MenuItem *item); virtual void menuItemSelected(Menu *menu, MenuItem *item);
// Added to support 'ticks' // Added to support 'ticks'
void processTick(); void processTick();

View file

@ -195,9 +195,9 @@ bool PopupMenu::onMessageObjectReceived(StringTableEntry queue, Message *msg )
// Console Methods // Console Methods
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
DefineConsoleMethod(PopupMenu, insertItem, S32, (S32 pos, const char * title, const char * accelerator), ("", ""), "(pos[, title][, accelerator])") DefineConsoleMethod(PopupMenu, insertItem, S32, (S32 pos, const char * title, const char * accelerator, const char* cmd), ("", "", ""), "(pos[, title][, accelerator][, cmd])")
{ {
return object->insertItem(pos, title, accelerator); return object->insertItem(pos, title, accelerator, cmd);
} }
DefineConsoleMethod(PopupMenu, removeItem, void, (S32 pos), , "(pos)") DefineConsoleMethod(PopupMenu, removeItem, void, (S32 pos), , "(pos)")
@ -216,9 +216,9 @@ DefineConsoleMethod(PopupMenu, insertSubMenu, S32, (S32 pos, String title, Strin
return object->insertSubMenu(pos, title, mnu); return object->insertSubMenu(pos, title, mnu);
} }
DefineConsoleMethod(PopupMenu, setItem, bool, (S32 pos, const char * title, const char * accelerator), (""), "(pos, title[, accelerator])") DefineConsoleMethod(PopupMenu, setItem, bool, (S32 pos, const char * title, const char * accelerator, const char *cmd), (""), "(pos, title[, accelerator][, cmd])")
{ {
return object->setItem(pos, title, accelerator); return object->setItem(pos, title, accelerator, cmd);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -85,11 +85,11 @@ public:
/// returns the menu item's ID, or -1 on failure. /// returns the menu item's ID, or -1 on failure.
/// implementd on a per-platform basis. /// implementd on a per-platform basis.
/// TODO: factor out common code /// TODO: factor out common code
S32 insertItem(S32 pos, const char *title, const char* accelerator); S32 insertItem(S32 pos, const char *title, const char* accelerator, const char* cmd);
/// Sets the name title and accelerator for /// Sets the name title and accelerator for
/// an existing item. /// an existing item.
bool setItem(S32 pos, const char *title, const char* accelerator); bool setItem(S32 pos, const char *title, const char* accelerator, const char* cmd);
/// pass NULL for @p title to insert a separator /// pass NULL for @p title to insert a separator
/// returns the menu item's ID, or -1 on failure. /// returns the menu item's ID, or -1 on failure.

View file

@ -37,6 +37,7 @@ enum MBButtons
MBRetryCancel, MBRetryCancel,
MBSaveDontSave, MBSaveDontSave,
MBSaveDontSaveCancel, MBSaveDontSaveCancel,
MBAlertAssert
}; };
enum MBIcons enum MBIcons

View file

@ -174,6 +174,15 @@ namespace Platform
bool isdst; ///< True if daylight savings time is active bool isdst; ///< True if daylight savings time is active
}; };
enum ALERT_ASSERT_RESULT
{
ALERT_ASSERT_DEBUG,
ALERT_ASSERT_IGNORE,
ALERT_ASSERT_IGNORE_ALL,
ALERT_ASSERT_EXIT
};
void getLocalTime(LocalTime &); void getLocalTime(LocalTime &);
/// Converts the local time to a formatted string appropriate /// Converts the local time to a formatted string appropriate
@ -300,6 +309,7 @@ namespace Platform
void AlertOK(const char *windowTitle, const char *message); void AlertOK(const char *windowTitle, const char *message);
bool AlertOKCancel(const char *windowTitle, const char *message); bool AlertOKCancel(const char *windowTitle, const char *message);
bool AlertRetry(const char *windowTitle, const char *message); bool AlertRetry(const char *windowTitle, const char *message);
ALERT_ASSERT_RESULT AlertAssert(const char *windowTitle, const char *message);
// Volumes // Volumes
struct VolumeInformation struct VolumeInformation

View file

@ -33,6 +33,7 @@ PlatformAssert *PlatformAssert::platformAssert = NULL;
PlatformAssert::PlatformAssert() PlatformAssert::PlatformAssert()
{ {
processing = false; processing = false;
ignoreAll = false;
} }
//-------------------------------------- //--------------------------------------
@ -94,47 +95,57 @@ bool PlatformAssert::process(Type assertType,
U32 lineNumber, U32 lineNumber,
const char *message) const char *message)
{ {
// If we're somehow recursing, just die. // If we're somehow recursing, just die.
if(processing) if(processing)
Platform::debugBreak(); Platform::debugBreak();
processing = true; processing = true;
bool ret = true; bool ret = false;
// always dump to the Assert to the Console // always dump to the Assert to the Console
if (Con::isActive()) if (Con::isActive())
{ {
if (assertType == Warning) if (assertType == Warning)
Con::warnf(ConsoleLogEntry::Assert, "%s(%ld) : %s - %s", filename, lineNumber, typeName[assertType], message); Con::warnf(ConsoleLogEntry::Assert, "%s(%ld,0): {%s} - %s", filename, lineNumber, typeName[assertType], message);
else else
Con::errorf(ConsoleLogEntry::Assert, "%s(%ld) : %s - %s", filename, lineNumber, typeName[assertType], message); Con::errorf(ConsoleLogEntry::Assert, "%s(%ld,0): {%s} - %s", filename, lineNumber, typeName[assertType], message);
} }
// if not a WARNING pop-up a dialog box // if not a WARNING pop-up a dialog box
if (assertType != Warning) if (assertType != Warning)
{ {
// used for processing navGraphs (an assert won't botch the whole build) // used for processing navGraphs (an assert won't botch the whole build)
if(Con::getBoolVariable("$FP::DisableAsserts", false) == true) if(Con::getBoolVariable("$FP::DisableAsserts", false) == true)
Platform::forceShutdown(1); Platform::forceShutdown(1);
char buffer[2048]; char buffer[2048];
dSprintf(buffer, 2048, "%s(%ld) : %s", filename, lineNumber, typeName[assertType] ); dSprintf(buffer, 2048, "%s: (%s @ %ld)", typeName[assertType], filename, lineNumber);
if( !ignoreAll )
#ifdef TORQUE_DEBUG {
// In debug versions, allow a retry even for ISVs... // Display message box with Debug, Ignore, Ignore All, and Exit options
bool retry = displayMessageBox(buffer, message, true); switch( Platform::AlertAssert(buffer, message) )
#else {
bool retry = displayMessageBox(buffer, message, ((assertType == Fatal) ? true : false) ); case Platform::ALERT_ASSERT_DEBUG:
#endif ret = true;
if(!retry) break;
Platform::forceShutdown(1); case Platform::ALERT_ASSERT_IGNORE:
ret = false;
ret = askToEnterDebugger(message); break;
} case Platform::ALERT_ASSERT_IGNORE_ALL:
ignoreAll = true;
processing = false; ret = false;
break;
return ret; default:
case Platform::ALERT_ASSERT_EXIT:
Platform::forceShutdown(1);
break;
}
}
}
processing = false;
return ret;
} }
bool PlatformAssert::processingAssert() bool PlatformAssert::processingAssert()
@ -170,3 +181,11 @@ const char* avar(const char *message, ...)
dVsprintf(buffer, sizeof(buffer), message, args); dVsprintf(buffer, sizeof(buffer), message, args);
return( buffer ); return( buffer );
} }
//-----------------------------------------------------------------------------
ConsoleFunction( Assert, void, 3, 3, "(condition, message) - Fatal Script Assertion" )
{
// Process Assertion.
AssertISV( dAtob(argv[1]), argv[2] );
}

View file

@ -40,6 +40,7 @@ public:
private: private:
static PlatformAssert *platformAssert; static PlatformAssert *platformAssert;
bool processing; bool processing;
bool ignoreAll;
virtual bool displayMessageBox(const char *title, const char *message, bool retry); virtual bool displayMessageBox(const char *title, const char *message, bool retry);
virtual bool process(Type assertType, virtual bool process(Type assertType,

View file

@ -41,6 +41,8 @@
// MenuBar Methods // MenuBar Methods
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef TORQUE_SDL
void MenuBar::createPlatformPopupMenuData() void MenuBar::createPlatformPopupMenuData()
{ {
// mData = new PlatformMenuBarData; // mData = new PlatformMenuBarData;
@ -171,3 +173,5 @@ void MenuBar::removeFromCanvas()
mCanvas = NULL; mCanvas = NULL;
} }
#endif

View file

@ -20,6 +20,8 @@
// IN THE SOFTWARE. // IN THE SOFTWARE.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef TORQUE_SDL
#include "platform/menus/popupMenu.h" #include "platform/menus/popupMenu.h"
#include "platformWin32/platformWin32.h" #include "platformWin32/platformWin32.h"
#include "console/consoleTypes.h" #include "console/consoleTypes.h"
@ -169,7 +171,7 @@ void PopupMenu::createPlatformMenu()
// Public Methods // Public Methods
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
S32 PopupMenu::insertItem(S32 pos, const char *title, const char* accelerator) S32 PopupMenu::insertItem(S32 pos, const char *title, const char* accelerator, const char *)
{ {
Win32Window *pWindow = mCanvas ? dynamic_cast<Win32Window*>(mCanvas->getPlatformWindow()) : NULL; Win32Window *pWindow = mCanvas ? dynamic_cast<Win32Window*>(mCanvas->getPlatformWindow()) : NULL;
bool isAttached = isAttachedToMenuBar(); bool isAttached = isAttachedToMenuBar();
@ -266,7 +268,7 @@ S32 PopupMenu::insertSubMenu(S32 pos, const char *title, PopupMenu *submenu)
return -1; return -1;
} }
bool PopupMenu::setItem(S32 pos, const char *title, const char* accelerator) bool PopupMenu::setItem(S32 pos, const char *title, const char* accelerator, const char *)
{ {
Win32Window *pWindow = mCanvas ? dynamic_cast<Win32Window*>(mCanvas->getPlatformWindow()) : NULL; Win32Window *pWindow = mCanvas ? dynamic_cast<Win32Window*>(mCanvas->getPlatformWindow()) : NULL;
bool isAttached = isAttachedToMenuBar(); bool isAttached = isAttachedToMenuBar();
@ -740,3 +742,4 @@ S32 PopupMenu::getPosOnMenuBar()
return pos; return pos;
} }
#endif

View file

@ -80,7 +80,7 @@ static U32 getMaskFromID(_FlagMap *map, S32 id)
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef TORQUE_SDL
S32 Platform::messageBox(const UTF8 *title, const UTF8 *message, MBButtons buttons, MBIcons icon) S32 Platform::messageBox(const UTF8 *title, const UTF8 *message, MBButtons buttons, MBIcons icon)
{ {
PlatformWindow *pWindow = WindowManager->getFirstWindow(); PlatformWindow *pWindow = WindowManager->getFirstWindow();
@ -127,3 +127,4 @@ S32 Platform::messageBox(const UTF8 *title, const UTF8 *message, MBButtons butto
return getMaskFromID(sgMsgBoxRetMap, ret); return getMaskFromID(sgMsgBoxRetMap, ret);
} }
#endif

View file

@ -153,6 +153,8 @@ DefineConsoleFunction( shellExecute, bool, (const char * executable, const char
return true; return true;
} }
#ifndef TORQUE_SDL
void Platform::openFolder(const char* path ) void Platform::openFolder(const char* path )
{ {
char filePath[1024]; char filePath[1024];
@ -187,3 +189,5 @@ void Platform::openFile(const char* path )
::ShellExecute( NULL,TEXT("open"),p, NULL, NULL, SW_SHOWNORMAL); ::ShellExecute( NULL,TEXT("open"),p, NULL, NULL, SW_SHOWNORMAL);
} }
#endif // !TORQUE_SDL

View file

@ -20,6 +20,7 @@
// IN THE SOFTWARE. // IN THE SOFTWARE.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if !defined( TORQUE_SDL )
#include "platformWin32/platformWin32.h" #include "platformWin32/platformWin32.h"
#include "platform/platformInput.h" #include "platform/platformInput.h"
@ -863,3 +864,4 @@ bool Platform::setClipboard(const char *text)
return true; return true;
} }
#endif

View file

@ -190,6 +190,7 @@ bool Platform::checkOtherInstances(const char *mutexName)
return false; return false;
} }
#ifndef TORQUE_SDL
//-------------------------------------- //--------------------------------------
void Platform::AlertOK(const char *windowTitle, const char *message) void Platform::AlertOK(const char *windowTitle, const char *message)
{ {
@ -232,6 +233,43 @@ bool Platform::AlertRetry(const char *windowTitle, const char *message)
#endif #endif
} }
Platform::ALERT_ASSERT_RESULT Platform::AlertAssert(const char *windowTitle, const char *message)
{
#ifndef TORQUE_TOOLS
ShowCursor(true);
#endif // TORQUE_TOOLS
#ifdef UNICODE
UTF16 messageUTF[1024], title[512];
convertUTF8toUTF16((UTF8 *)windowTitle, title, sizeof(title));
convertUTF8toUTF16((UTF8 *)message, messageUTF, sizeof(messageUTF));
#else
const char* messageUTF = message;
const char* title = windowTitle;
#endif
// TODO: Change this to a custom dialog that has Exit, Ignore, Ignore All, and Debug buttons
ALERT_ASSERT_RESULT alertResult = ALERT_ASSERT_DEBUG;
int result = MessageBox(winState.appWindow, messageUTF, title, MB_ABORTRETRYIGNORE | MB_ICONSTOP | MB_DEFBUTTON2 | MB_TASKMODAL | MB_SETFOREGROUND);
switch( result )
{
case IDABORT:
alertResult = ALERT_ASSERT_EXIT;
break;
case IDIGNORE:
alertResult = ALERT_ASSERT_IGNORE;
break;
default:
case IDRETRY:
alertResult = ALERT_ASSERT_DEBUG;
break;
}
return alertResult;
}
#endif
//-------------------------------------- //--------------------------------------
HIMC gIMEContext; HIMC gIMEContext;

View file

@ -107,6 +107,7 @@ void Platform::AlertOK(const char *, const char *) {}
bool Platform::AlertOKCancel(const char *, const char *) { return false; } bool Platform::AlertOKCancel(const char *, const char *) { return false; }
S32 Platform::messageBox(char const*, char const*, MBButtons, MBIcons) { return 0; } S32 Platform::messageBox(char const*, char const*, MBButtons, MBIcons) { return 0; }
bool Platform::AlertRetry(char const*, char const*) { return false ; } bool Platform::AlertRetry(char const*, char const*) { return false ; }
Platform::ALERT_ASSERT_RESULT Platform::AlertAssert(const char *windowTitle, const char *message) { return ALERT_ASSERT_EXIT; }
// file dialog // file dialog
IMPLEMENT_CONOBJECT(FileDialog); IMPLEMENT_CONOBJECT(FileDialog);

View file

@ -136,7 +136,7 @@ HWND getWin32WindowHandle()
return NULL; return NULL;
} }
return ( ( Win32Window* ) window )->getHWND(); return (HWND)window->getSystemWindow( PlatformWindow::WindowSystem_Windows );
} }
#endif #endif

View file

@ -124,10 +124,21 @@ public:
/// Get the WindowController associated with this window /// Get the WindowController associated with this window
virtual void setInputController( IProcessInput *controller ) { if( mWindowInputGenerator ) mWindowInputGenerator->setInputController( controller ); }; virtual void setInputController( IProcessInput *controller ) { if( mWindowInputGenerator ) mWindowInputGenerator->setInputController( controller ); };
WindowInputGenerator* getInputGenerator() const { return mWindowInputGenerator; }
/// Get the ID that uniquely identifies this window in the context of its /// Get the ID that uniquely identifies this window in the context of its
/// window manager. /// window manager.
virtual WindowId getWindowId() { return 0; }; virtual WindowId getWindowId() { return 0; };
enum WindowSystem
{
WindowSystem_Unknown = 0,
WindowSystem_Windows,
WindowSystem_X11,
};
virtual void* getSystemWindow(const WindowSystem system) { return NULL; }
/// Set the flag that determines whether to suppress a GFXDevice reset /// Set the flag that determines whether to suppress a GFXDevice reset
inline void setSuppressReset(bool suppress) { mSuppressReset = suppress; }; inline void setSuppressReset(bool suppress) { mSuppressReset = suppress; };

View file

@ -121,6 +121,8 @@ void CloseSplashWindow(HINSTANCE hinst)
} }
#ifndef TORQUE_SDL
bool Platform::closeSplashWindow() bool Platform::closeSplashWindow()
{ {
CloseSplashWindow(GetModuleHandle(NULL)); CloseSplashWindow(GetModuleHandle(NULL));
@ -155,4 +157,4 @@ bool Platform::displaySplashWindow( String path )
return true; return true;
} }
#endif

View file

@ -20,6 +20,8 @@
// IN THE SOFTWARE. // IN THE SOFTWARE.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if !defined(TORQUE_SDL)
#include <windows.h> #include <windows.h>
#include <tchar.h> #include <tchar.h>
#include <winuser.h> #include <winuser.h>
@ -121,6 +123,14 @@ Win32Window::~Win32Window()
_unregisterWindowClass(); _unregisterWindowClass();
} }
void* Win32Window::getSystemWindow(const WindowSystem system)
{
if( system == WindowSystem_Windows)
return getHWND();
return NULL;
}
GFXDevice * Win32Window::getGFXDevice() GFXDevice * Win32Window::getGFXDevice()
{ {
return mDevice; return mDevice;
@ -1209,3 +1219,5 @@ const UTF16 *Win32Window::getCurtainWindowClassName()
{ {
return _CurtainWindowClassName; return _CurtainWindowClassName;
} }
#endif

View file

@ -139,6 +139,8 @@ public:
return mWindowHandle; return mWindowHandle;
} }
virtual void* getSystemWindow(const WindowSystem system);
HMENU &getMenuHandle() HMENU &getMenuHandle()
{ {
return mMenuHandle; return mMenuHandle;

View file

@ -27,6 +27,8 @@
#include "core/util/journal/process.h" #include "core/util/journal/process.h"
#include "core/strings/unicode.h" #include "core/strings/unicode.h"
#if !defined( TORQUE_SDL )
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void CloseSplashWindow(HINSTANCE hinst); void CloseSplashWindow(HINSTANCE hinst);
@ -522,4 +524,6 @@ void Win32WindowManager::raiseCurtain()
DestroyWindow(mCurtainWindow); DestroyWindow(mCurtainWindow);
mCurtainWindow = NULL; mCurtainWindow = NULL;
} }
#endif

View file

@ -39,6 +39,8 @@
#include "core/util/journal/process.h" #include "core/util/journal/process.h"
#include "core/util/journal/journaledSignal.h" #include "core/util/journal/journaledSignal.h"
#if !defined( TORQUE_SDL )
static U32 _ModifierKeys=0; static U32 _ModifierKeys=0;
static BYTE keyboardState[256]; static BYTE keyboardState[256];
static bool initKBState = false; static bool initKBState = false;
@ -591,3 +593,6 @@ void DispatchRemove(HWND hWnd)
{ {
_MessageQueue.remove(hWnd); _MessageQueue.remove(hWnd);
} }
#endif

View file

@ -85,6 +85,19 @@ void WindowInputGenerator::generateInputEvent( InputEventInfo &inputEvent )
if( !mInputController || !mFocused ) if( !mInputController || !mFocused )
return; return;
if (inputEvent.action == SI_MAKE && inputEvent.deviceType == KeyboardDeviceType)
{
for( int i = 0; i < mAcceleratorMap.size(); ++i )
{
const AccKeyMap &acc = mAcceleratorMap[i];
if( acc.modifier & inputEvent.modifier && acc.keyCode == inputEvent.objInst )
{
Con::evaluatef(acc.cmd);
return;
}
}
}
// Give the ActionMap first shot. // Give the ActionMap first shot.
if (ActionMap::handleEventGlobal(&inputEvent)) if (ActionMap::handleEventGlobal(&inputEvent))
return; return;

View file

@ -61,6 +61,16 @@ class WindowInputGenerator
void handleInputEvent (U32 deviceInst, F32 fValue, F32 fValue2, F32 fValue3, F32 fValue4, S32 iValue, U16 deviceType, U16 objType, U16 ascii, U16 objInst, U8 action, U8 modifier); void handleInputEvent (U32 deviceInst, F32 fValue, F32 fValue2, F32 fValue3, F32 fValue4, S32 iValue, U16 deviceType, U16 objType, U16 ascii, U16 objInst, U8 action, U8 modifier);
void generateInputEvent( InputEventInfo &inputEvent ); void generateInputEvent( InputEventInfo &inputEvent );
/// Accelerator key map
struct AccKeyMap
{
void *hnd;
String cmd;
U32 keyCode;
U32 modifier;
};
Vector <AccKeyMap> mAcceleratorMap;
public: public:
@ -72,6 +82,42 @@ class WindowInputGenerator
/// Returns true if the given keypress event should be send as a raw keyboard /// Returns true if the given keypress event should be send as a raw keyboard
/// event even if it maps to a character input event. /// event even if it maps to a character input event.
bool wantAsKeyboardEvent( U32 modifiers, U32 key ); bool wantAsKeyboardEvent( U32 modifiers, U32 key );
void addAcceleratorKey( void *hnd, const String &cmd, U32 keycode, U32 modifier)
{
AccKeyMap acc;
acc.hnd = hnd;
acc.cmd = cmd;
acc.keyCode = keycode;
acc.modifier = modifier;
mAcceleratorMap.push_back(acc);
}
void removeAcceleratorKeys( void *hnd )
{
for( int i = 0; i < mAcceleratorMap.size(); )
{
if( mAcceleratorMap[i].hnd == hnd )
{
mAcceleratorMap.erase( i, 1 );
continue;
}
++i;
}
}
void removeAcceleratorKey( void *hnd, U32 keycode, U32 modifier )
{
for( int i = 0; i < mAcceleratorMap.size(); ++i )
{
if( mAcceleratorMap[i].hnd == hnd && mAcceleratorMap[i].keyCode == keycode && mAcceleratorMap[i].modifier == modifier )
{
mAcceleratorMap.erase( i, 1 );
return;
}
}
}
}; };
#endif // _WINDOW_INPUTGENERATOR_H_ #endif // _WINDOW_INPUTGENERATOR_H_

View file

@ -35,6 +35,7 @@ exec("./GuiEaseEditDlg.ed.cs");
exec("./guiObjectInspector.ed.cs"); exec("./guiObjectInspector.ed.cs");
exec("./uvEditor.ed.gui"); exec("./uvEditor.ed.gui");
exec("./objectSelection.ed.cs"); exec("./objectSelection.ed.cs");
exec("./guiPlatformGenericMenubar.ed.cs");
if (isDemo()) if (isDemo())
exec("./messageBoxOKBuy.ed.gui"); exec("./messageBoxOKBuy.ed.gui");

View file

@ -1063,3 +1063,15 @@ singleton GuiControlProfile( GuiCreatorIconButtonProfile )
//bevelColorLL = "0 0 0"; //bevelColorLL = "0 0 0";
category = "Editor"; category = "Editor";
}; };
singleton GuiControlProfile( GuiMenuBarProfile )
{
fillcolor = "255 255 255";
borderColor = "0 0 0";
border = 1;
borderThickness = 1;
opaque = true;
mouseOverSelected = true;
category = "Editor";
bitmap = "tools/gui/images/checkbox-menubar";
};

View file

@ -35,6 +35,7 @@ exec("./GuiEaseEditDlg.ed.cs");
exec("./guiObjectInspector.ed.cs"); exec("./guiObjectInspector.ed.cs");
exec("./uvEditor.ed.gui"); exec("./uvEditor.ed.gui");
exec("./objectSelection.ed.cs"); exec("./objectSelection.ed.cs");
exec("./guiPlatformGenericMenubar.ed.cs");
if (isDemo()) if (isDemo())
exec("./messageBoxOKBuy.ed.gui"); exec("./messageBoxOKBuy.ed.gui");

View file

@ -1063,3 +1063,15 @@ singleton GuiControlProfile( GuiCreatorIconButtonProfile )
//bevelColorLL = "0 0 0"; //bevelColorLL = "0 0 0";
category = "Editor"; category = "Editor";
}; };
singleton GuiControlProfile( GuiMenuBarProfile )
{
fillcolor = "255 255 255";
borderColor = "0 0 0";
border = 1;
borderThickness = 1;
opaque = true;
mouseOverSelected = true;
category = "Editor";
bitmap = "tools/gui/images/checkbox-menubar";
};