forked from Mirrorlandia_minetest/irrlicht
Minor improvements and cleanup for example 24.CursorControl
- ESC now also makes cursor visible again (probably first key users press in panic usually) - Bunch of spelling fixes - Let all words in UI elements start with upper-case git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6317 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
60538c3646
commit
f0c890d3ff
@ -1,6 +1,6 @@
|
||||
/** Example 024 CursorControl
|
||||
|
||||
Show how to modify cursors and offer some useful tool-functions for creating cursors.
|
||||
Show how to modify cursors and offer some useful tool functions for creating cursors.
|
||||
It can also be used for experiments with the mouse in general.
|
||||
*/
|
||||
|
||||
@ -142,7 +142,7 @@ void PrintMouseEventName(const SEvent& event, stringw &result)
|
||||
}
|
||||
|
||||
/*
|
||||
Helper function to print all the state information which get from a mouse-event into a stringw
|
||||
Helper function to print all the state information from a mouse event into a stringw
|
||||
*/
|
||||
void PrintMouseState(const SEvent& event, stringw &result)
|
||||
{
|
||||
@ -295,6 +295,17 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if ( event.EventType == EET_KEY_INPUT_EVENT)
|
||||
{
|
||||
// Allow invisible cursor to show up again when users presses ESC
|
||||
if ( !event.KeyInput.PressedDown && event.KeyInput.Key == irr::KEY_ESCAPE )
|
||||
{
|
||||
TimerAction action;
|
||||
action.Action = ETA_MOUSE_VISIBLE;
|
||||
Context.runTimerAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -303,7 +314,7 @@ private:
|
||||
};
|
||||
|
||||
/*
|
||||
Use several imagefiles as animation frames for a sprite which can be used as cursor icon.
|
||||
Use several image files as animation frames for a sprite which can then be used as a cursor icon.
|
||||
The images in those files all need to have the same size.
|
||||
Return sprite index on success or -1 on failure
|
||||
*/
|
||||
@ -345,7 +356,7 @@ s32 AddAnimatedIconToSpriteBank( gui::IGUISpriteBank * spriteBank, video::IVideo
|
||||
}
|
||||
|
||||
/*
|
||||
Use several images within one imagefile as animation frames for a sprite which can be used as cursor icon
|
||||
Use several images within one image file as animation frames for a sprite which can then be used as a cursor icon
|
||||
The sizes of the icons within that file all need to have the same size
|
||||
Return sprite index on success or -1 on failure
|
||||
*/
|
||||
@ -433,8 +444,6 @@ int main()
|
||||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
IGUIEnvironment* env = device->getGUIEnvironment();
|
||||
|
||||
gui::IGUISpriteBank * SpriteBankIcons;
|
||||
|
||||
SAppContext context;
|
||||
context.Device = device;
|
||||
|
||||
@ -443,23 +452,24 @@ int main()
|
||||
rectInfoStatic.UpperLeftCorner += dimension2di(0, 15);
|
||||
context.InfoStatic = env->addStaticText (L"", rectInfoStatic, true, true);
|
||||
rect< s32 > rectEventBox(10,210, 200, 400);
|
||||
env->addStaticText (L"click events (new on top)", rectEventBox, true, true);
|
||||
env->addStaticText (L"Click events (new on top)", rectEventBox, true, true);
|
||||
rectEventBox.UpperLeftCorner += dimension2di(0, 15);
|
||||
context.EventBox = env->addListBox(rectEventBox);
|
||||
rect< s32 > rectCursorBox(210,10, 400, 250);
|
||||
env->addStaticText (L"cursors, click to set the active one", rectCursorBox, true, true);
|
||||
env->addStaticText (L"Cursors, click to set the active one", rectCursorBox, true, true);
|
||||
rectCursorBox.UpperLeftCorner += dimension2di(0, 15);
|
||||
context.CursorBox = env->addListBox(rectCursorBox);
|
||||
rect< s32 > rectSpriteBox(210,260, 400, 400);
|
||||
env->addStaticText (L"sprites", rectSpriteBox, true, true);
|
||||
env->addStaticText (L"Sprites", rectSpriteBox, true, true);
|
||||
rectSpriteBox.UpperLeftCorner += dimension2di(0, 15);
|
||||
context.SpriteBox = env->addListBox(rectSpriteBox);
|
||||
|
||||
context.ButtonSetVisible = env->addButton( rect<s32>( 410, 20, 560, 40 ), 0, -1, L"set visible (delayed)" );
|
||||
context.ButtonSetInvisible = env->addButton( rect<s32>( 410, 50, 560, 70 ), 0, -1, L"set invisible (delayed)" );
|
||||
context.ButtonSimulateBadFps = env->addButton( rect<s32>( 410, 80, 560, 100 ), 0, -1, L"simulate bad FPS" );
|
||||
context.ButtonSetVisible = env->addButton( rect<s32>( 410, 20, 560, 40 ), 0, -1, L"Set visible (delayed)" );
|
||||
context.ButtonSetInvisible = env->addButton( rect<s32>( 410, 50, 560, 70 ), 0, -1, L"Set invisible (delayed)" );
|
||||
context.ButtonSimulateBadFps = env->addButton( rect<s32>( 410, 80, 560, 100 ), 0, -1, L"Simulate bad FPS" );
|
||||
context.ButtonSimulateBadFps->setIsPushButton(true);
|
||||
context.ButtonChangeIcon = env->addButton( rect<s32>( 410, 140, 560, 160 ), 0, -1, L"replace cursor icon\n(cursor+sprite must be selected)" );
|
||||
s32 t = context.SpriteBox->getAbsolutePosition().UpperLeftCorner.Y;
|
||||
context.ButtonChangeIcon = env->addButton( rect<s32>( 410, t, 560, t+20), 0, -1, L"Replace cursor icon\n(cursor+sprite must be selected)" );
|
||||
|
||||
// set the names for all the system cursors
|
||||
for ( int i=0; i < (int)gui::ECI_COUNT; ++i )
|
||||
@ -470,7 +480,7 @@ int main()
|
||||
/*
|
||||
Create sprites which then can be used as cursor icons.
|
||||
*/
|
||||
SpriteBankIcons = env->addEmptySpriteBank(io::path("cursor_icons"));
|
||||
gui::IGUISpriteBank * SpriteBankIcons = env->addEmptySpriteBank(io::path("cursor_icons"));
|
||||
context.SpriteBox->setSpriteBank(SpriteBankIcons);
|
||||
|
||||
const io::path mediaPath = getExampleMediaPath();
|
||||
@ -546,7 +556,8 @@ int main()
|
||||
driver->endScene();
|
||||
}
|
||||
|
||||
// By simulating bad fps we can find out if hardware-support for cursors works or not. If it works the cursor will move as usual,while it otherwise will just update with 2 fps now.
|
||||
// By simulating a bad frame rate we can find out if hardware support for cursors works or not.
|
||||
// If it works the cursor will move as usual, otherwise it will update with only 2 fps when SimulateBadFps is true.
|
||||
if ( context.SimulateBadFps )
|
||||
{
|
||||
device->sleep(500); // 2 fps
|
||||
|
Loading…
Reference in New Issue
Block a user