mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-19 15:09:43 +00:00
More work on the MyGUI skins and layouts
git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@86 ea6a568a-9f4f-0410-981a-c910a81bb256
This commit is contained in:
parent
fdf9da706f
commit
9530ae0526
18 changed files with 511 additions and 1465 deletions
|
@ -237,6 +237,7 @@ struct ConfigManager
|
|||
bind(Keys.ToggleBattleMusic, KC.SPACE);
|
||||
bind(Keys.PhysMode, KC.T);
|
||||
bind(Keys.Nighteye, KC.N);
|
||||
bind(Keys.ToggleGui, KC.Mouse1);
|
||||
bind(Keys.Debug, KC.G);
|
||||
|
||||
bind(Keys.Pause, KC.PAUSE, KC.P);
|
||||
|
|
|
@ -266,21 +266,11 @@ struct ResourceManager
|
|||
|
||||
// Create a new resource locator
|
||||
ti = esmRegion.newT!(TextureResource);
|
||||
|
||||
|
||||
ti.name = esmRegion.copyz(id);
|
||||
ti.newName = ti.name;
|
||||
ti.type = ti.name[$-3..$];
|
||||
|
||||
char tmp[];
|
||||
if(id.length < 70)
|
||||
{
|
||||
// See comment in lookupMesh
|
||||
texBuffer[9..9+id.length] = id;
|
||||
tmp = texBuffer[0..9+id.length];
|
||||
}
|
||||
else
|
||||
tmp = "textures\\" ~ id;
|
||||
|
||||
void searchBSAs(char[] search)
|
||||
{
|
||||
// Look it up in the BSA
|
||||
|
@ -297,30 +287,54 @@ struct ResourceManager
|
|||
}
|
||||
}
|
||||
|
||||
searchBSAs(tmp);
|
||||
|
||||
// If we can't find it, try the same filename but with .dds as the
|
||||
// extension. Bethesda did at some point convert all their
|
||||
// textures to dds to improve loading times. However, they did not
|
||||
// update their esm-files or require them to use the correct
|
||||
// extention (if they had, it would have broken a lot of user
|
||||
// mods). So we must support files that are referenced as eg .tga
|
||||
// but stored as .dds.
|
||||
if(ti.bsaIndex == -1 && ti.type != "dds")
|
||||
void searchWithDDS(char[] search)
|
||||
{
|
||||
tmp[$-3..$] = "dds";
|
||||
searchBSAs(tmp);
|
||||
if(ti.bsaIndex != -1)
|
||||
{
|
||||
// Store the real name in newName.
|
||||
ti.newName = esmRegion.copyz(ti.name);
|
||||
searchBSAs(search);
|
||||
|
||||
// Get a slice of the extension and overwrite it.
|
||||
ti.type = ti.newName[$-3..$];
|
||||
ti.type[] = "dds";
|
||||
// If we can't find it, try the same filename but with .dds as
|
||||
// the extension. Bethesda did at some point convert all their
|
||||
// textures to dds to improve loading times. However, they did
|
||||
// not update their esm-files or require them to use the
|
||||
// correct extention (if they had, it would have broken a lot
|
||||
// of user mods). So we must support files that are referenced
|
||||
// as eg .tga but stored as .dds.
|
||||
if(ti.bsaIndex == -1 && ti.type != "dds")
|
||||
{
|
||||
search[$-3..$] = "dds";
|
||||
searchBSAs(search);
|
||||
if(ti.bsaIndex != -1)
|
||||
{
|
||||
// Store the real name in newName.
|
||||
ti.newName = esmRegion.copyz(ti.name);
|
||||
|
||||
// Get a slice of the extension and overwrite it.
|
||||
ti.type = ti.newName[$-3..$];
|
||||
ti.type[] = "dds";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Search for 'texture\name' first
|
||||
char[] tmp;
|
||||
if(id.length < 70)
|
||||
{
|
||||
tmp = texBuffer[0..9+id.length];
|
||||
tmp[9..$] = id;
|
||||
}
|
||||
else
|
||||
tmp = "textures\\" ~ id;
|
||||
|
||||
searchWithDDS(tmp);
|
||||
|
||||
// Not found? If so, try without the 'texture\'
|
||||
if(ti.bsaIndex == -1)
|
||||
{
|
||||
tmp = tmp[9..$];
|
||||
tmp[] = id; // Reset the name (replace .dds with the original)
|
||||
|
||||
searchWithDDS(tmp);
|
||||
}
|
||||
|
||||
// Check that extensions match, to be on the safe side
|
||||
assert(ti.type == ti.newName[$-3..$]);
|
||||
|
||||
|
|
|
@ -186,6 +186,7 @@ extern(C) void d_handleKey(KC keycode, dchar text = 0)
|
|||
|
||||
case Keys.PhysMode: bullet_nextMode(); break;
|
||||
case Keys.Nighteye: ogre_toggleLight(); break;
|
||||
case Keys.ToggleGui: gui_toggleGui(); break;
|
||||
|
||||
case Keys.Debug: break;
|
||||
case Keys.ScreenShot: takeScreenShot(); break;
|
||||
|
@ -237,7 +238,7 @@ bool isPressed(Keys key)
|
|||
return false;
|
||||
}
|
||||
|
||||
extern(C) int d_frameStarted(float time)
|
||||
extern(C) int d_frameStarted(float time, int guiMode)
|
||||
{
|
||||
if(doExit) return 0;
|
||||
|
||||
|
@ -251,8 +252,8 @@ extern(C) int d_frameStarted(float time)
|
|||
musCumTime -= musRefresh;
|
||||
}
|
||||
|
||||
// The rest is ignored in pause mode
|
||||
if(pause) return 1;
|
||||
// The rest is ignored in pause or GUI mode
|
||||
if(pause || guiMode == 1) return 1;
|
||||
|
||||
// Walking / floating speed, in points per second.
|
||||
const float speed = 300;
|
||||
|
@ -267,7 +268,7 @@ extern(C) int d_frameStarted(float time)
|
|||
if(isPressed(Keys.MoveBackward)) moveZ += speed;
|
||||
|
||||
// TODO: These should be enabled for floating modes (like swimming
|
||||
// and levitation) only.
|
||||
// and levitation) and disabled for everything else.
|
||||
if(isPressed(Keys.MoveUp)) moveY += speed;
|
||||
if(isPressed(Keys.MoveDown)) moveY -= speed;
|
||||
|
||||
|
@ -300,6 +301,7 @@ extern(C) int d_frameStarted(float time)
|
|||
bullet_getPlayerPos(&x, &y, &z);
|
||||
ogre_moveCamera(x,y,z);
|
||||
|
||||
// Tell the sound scene that the player has moved
|
||||
sndCumTime += time;
|
||||
if(sndCumTime > sndRefresh)
|
||||
{
|
||||
|
|
|
@ -67,6 +67,7 @@ enum Keys
|
|||
ToggleBattleMusic,
|
||||
PhysMode, // Toggle physics mode between walking, flying and ghost
|
||||
Nighteye, // Full ambient lighting
|
||||
ToggleGui, // Turn the GUI on/off
|
||||
Debug,
|
||||
|
||||
// Misc
|
||||
|
@ -252,6 +253,7 @@ struct KeyBindings
|
|||
keyToString[Keys.ToggleBattleMusic] = "Toggle Battle Music";
|
||||
keyToString[Keys.PhysMode] = "Toggle Physics Mode";
|
||||
keyToString[Keys.Nighteye] = "Toggle Nighteye";
|
||||
keyToString[Keys.ToggleGui] = "Toggle GUI";
|
||||
keyToString[Keys.Debug] = "OGRE Test Action";
|
||||
|
||||
keyToString[Keys.Pause] = "Pause";
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,16 +3,19 @@
|
|||
<MyGUI>
|
||||
|
||||
<MyGUI type="List">
|
||||
<List file="core.lang" group="General"/>
|
||||
<List file="core.layer" group="General"/>
|
||||
<!--List file="core.lang" group="General"/-->
|
||||
<!--List file="core.layer" group="General"/-->
|
||||
<List file="core.skin" group="General"/>
|
||||
<List file="core.font" group="General"/>
|
||||
<List file="core.plugin"/>
|
||||
|
||||
<List file="openmw.pointer" group="General"/>
|
||||
<List file="openmw_windows.skin" group="General"/>
|
||||
<List file="openmw_button.skin" group="General"/>
|
||||
<List file="openmw.font" group="General"/>
|
||||
<List file="openmw_layers.xml" group="General"/>
|
||||
<List file="openmw.pointer.xml" group="General"/>
|
||||
<List file="openmw.font.xml" group="General"/>
|
||||
<List file="openmw_text.skin.xml" group="General"/>
|
||||
<List file="openmw_windows.skin.xml" group="General"/>
|
||||
<List file="openmw_button.skin.xml" group="General"/>
|
||||
<List file="openmw_hud_energybar.skin.xml" group="General"/>
|
||||
<List file="openmw_hud_box.skin.xml" group="General"/>
|
||||
</MyGUI>
|
||||
|
||||
</MyGUI>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Font">
|
||||
<!--
|
||||
<Font name="gothic" source="gothic.ttf" size="18" resolution="72" antialias_colour="false" space_width="4" tab_count="4" spacer="5">
|
||||
<Code range="33 126"/>
|
||||
<Code range="1025 1105"/>
|
||||
|
@ -18,6 +17,13 @@
|
|||
<Code hide="1104"/>
|
||||
</Font>
|
||||
|
||||
<Font name="daedric_orig" source="daedric_orig.ttf" size="18" resolution="72" antialias_colour="false" space_width="4" tab_count="4" spacer="5">
|
||||
<Code range="33 98"/>
|
||||
<Code hide="128"/>
|
||||
<Code hide="1026 1039"/>
|
||||
<Code hide="1104"/>
|
||||
</Font>
|
||||
|
||||
<Font name="cards" default_height="17" source="magiccards.ttf" size="18" resolution="50" antialias_colour="false" space_width="4" tab_width="8" cursor_width="2" distance="5" offset_height="0">
|
||||
<Code range="33 98"/>
|
||||
</Font>
|
||||
|
@ -39,5 +45,4 @@
|
|||
<Code hide="1026 1039"/>
|
||||
<Code hide="1104"/>
|
||||
</Font>
|
||||
-->
|
||||
</MyGUI>
|
|
@ -60,7 +60,7 @@
|
|||
<Child type="Widget" skin="BTN_BottomLeft" offset="0 20 4 4" align="ALIGN_BOTTOM ALIGN_LEFT"/>
|
||||
<Child type="Widget" skin="BTN_BottomRight" offset="132 20 4 4" align="ALIGN_BOTTOM ALIGN_RIGHT"/>
|
||||
|
||||
<BasisSkin type="SimpleText" offset = "4 4 128 16" align = "ALIGN_STRETCH">
|
||||
<BasisSkin type="SimpleText" offset="4 4 128 16" align="ALIGN_STRETCH">
|
||||
<!--State name="disable" colour="0.87 0.87 0.87"/-->
|
||||
<!--State name="normal" colour="0 0 0"/-->
|
||||
<State name="active" colour="FF0000"/>
|
22
media_mygui/openmw_hud_box.skin.xml
Normal file
22
media_mygui/openmw_hud_box.skin.xml
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Skin">
|
||||
<!-- The 'box' frame that surrounds various HUD items -->
|
||||
<Skin name="HUD_Box" size="40 40" texture="menu_icon_equip.dds">
|
||||
<BasisSkin type="SubSkin" offset="0 0 40 2" align= "ALIGN_TOP ALIGN_HSTRETCH">
|
||||
<State name="normal" offset="2 2 40 2"/>
|
||||
</BasisSkin>
|
||||
<BasisSkin type="SubSkin" offset="0 38 40 2" align= "ALIGN_BOTTOM ALIGN_HSTRETCH">
|
||||
<State name="normal" offset="2 40 40 2"/>
|
||||
</BasisSkin>
|
||||
<BasisSkin type="SubSkin" offset="0 2 2 36" align= "ALIGN_LEFT ALIGN_VSTRETCH">
|
||||
<State name="normal" offset="2 4 2 36"/>
|
||||
</BasisSkin>
|
||||
<BasisSkin type="SubSkin" offset="38 2 2 36" align= "ALIGN_RIGHT ALIGN_VSTRETCH">
|
||||
<State name="normal" offset="40 4 2 36"/>
|
||||
</BasisSkin>
|
||||
|
||||
<!-- The interior of the box -->
|
||||
<Child type="Widget" skin="BlackBG" offset="2 2 36 36" align="ALIGN_STRETCH" name="Client"/>
|
||||
</Skin>
|
||||
</MyGUI>
|
85
media_mygui/openmw_hud_energybar.skin.xml
Normal file
85
media_mygui/openmw_hud_energybar.skin.xml
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Skin">
|
||||
<!-- Energy bar frame graphics -->
|
||||
<Skin name="HUD_Bar_Top" size="64 2" texture="menu_small_energy_bar_top.dds">
|
||||
<BasisSkin type="MainSkin" offset = "0 0 64 2">
|
||||
<State name="normal" offset = "0 0 64 2"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
<Skin name="HUD_Bar_Bottom" size="64 2" texture="menu_small_energy_bar_bottom.dds">
|
||||
<BasisSkin type="MainSkin" offset = "0 0 64 2">
|
||||
<State name="normal" offset = "0 0 64 2"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
<Skin name="HUD_Bar_Side" size="2 8" texture="menu_small_energy_bar_vert.dds">
|
||||
<BasisSkin type="MainSkin" offset = "0 0 2 8">
|
||||
<State name="normal" offset = "0 0 2 8"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
|
||||
<Skin name="MW_BarFrame" size="64 12">
|
||||
<!-- Edges -->
|
||||
<Child type="Widget" skin="HUD_Bar_Top" offset="0 0 64 2" align="ALIGN_HSTRETCH ALIGN_TOP"/>
|
||||
<Child type="Widget" skin="HUD_Bar_Bottom" offset="0 10 64 2" align="ALIGN_HSTRETCH ALIGN_BOTTOM"/>
|
||||
<Child type="Widget" skin="HUD_Bar_Side" offset="0 2 2 8" align="ALIGN_VSTRETCH ALIGN_LEFT"/>
|
||||
<Child type="Widget" skin="HUD_Bar_Side" offset="62 2 2 8" align="ALIGN_VSTRETCH ALIGN_RIGHT"/>
|
||||
</Skin>
|
||||
|
||||
<!-- Progress bar track, various colors -->
|
||||
<Skin name = "MW_BarTrack_Red" size = "16 8" texture = "menu_bar_red.dds" >
|
||||
<BasisSkin type="MainSkin" offset = "0 0 16 8" align = "ALIGN_STRETCH">
|
||||
<State name="normal" offset = "0 8 16 8"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
<Skin name = "MW_BarTrack_Green" size = "16 8" texture = "menu_bar_green.dds" >
|
||||
<BasisSkin type="MainSkin" offset = "0 0 16 8" align = "ALIGN_STRETCH">
|
||||
<State name="normal" offset = "0 8 16 8"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
<Skin name = "MW_BarTrack_Blue" size = "16 8" texture = "menu_bar_blue.dds" >
|
||||
<BasisSkin type="MainSkin" offset = "0 0 16 8" align = "ALIGN_STRETCH">
|
||||
<State name="normal" offset = "0 8 16 8"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
<Skin name = "MW_BarTrack_Gray" size = "16 8" texture = "menu_bar_gray.dds" >
|
||||
<BasisSkin type="MainSkin" offset = "0 0 16 8" align = "ALIGN_STRETCH">
|
||||
<State name="normal" offset = "0 8 16 8"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
|
||||
<!-- Main energy bar widget definitions. There's one for each color.-->
|
||||
|
||||
<Skin name="MW_EnergyBar_Red" size="64 12">
|
||||
<Property key="TrackSkin" value = "MW_BarTrack_Red" />
|
||||
<Property key="TrackWidth" value = "1" />
|
||||
|
||||
<Child type="Widget" skin="MW_BarFrame" offset="0 0 64 12" align="ALIGN_STRETCH"/>
|
||||
<Child type="Widget" skin="BlackBG" offset = "2 2 60 8" align = "ALIGN_STRETCH" name="Client"/>
|
||||
</Skin>
|
||||
|
||||
<Skin name="MW_EnergyBar_Green" size="64 12">
|
||||
<Property key="TrackSkin" value = "MW_BarTrack_Green" />
|
||||
<Property key="TrackWidth" value = "1" />
|
||||
|
||||
<Child type="Widget" skin="MW_BarFrame" offset="0 0 64 12" align="ALIGN_STRETCH"/>
|
||||
<Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="ALIGN_STRETCH" name="Client"/>
|
||||
</Skin>
|
||||
|
||||
<Skin name="MW_EnergyBar_Blue" size="64 12">
|
||||
<Property key="TrackSkin" value = "MW_BarTrack_Blue" />
|
||||
<Property key="TrackWidth" value = "1" />
|
||||
|
||||
<Child type="Widget" skin="MW_BarFrame" offset="0 0 64 12" align="ALIGN_STRETCH"/>
|
||||
<Child type="Widget" skin="BlackBG" offset = "2 2 60 8" align = "ALIGN_STRETCH" name="Client"/>
|
||||
</Skin>
|
||||
|
||||
<Skin name="MW_EnergyBar_Gray" size="64 12">
|
||||
<Property key="TrackSkin" value = "MW_BarTrack_Gray" />
|
||||
<Property key="TrackWidth" value = "1" />
|
||||
|
||||
<Child type="Widget" skin="MW_BarFrame" offset="0 0 64 12" align="ALIGN_STRETCH"/>
|
||||
<Child type="Widget" skin="BlackBG" offset = "2 2 60 8" align = "ALIGN_STRETCH" name="Client"/>
|
||||
</Skin>
|
||||
|
||||
</MyGUI>
|
47
media_mygui/openmw_hud_layout.xml
Normal file
47
media_mygui/openmw_hud_layout.xml
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="Widget" layer="HUD" position="0 0 300 200" name="_Main">
|
||||
<!-- Energy bars -->
|
||||
<Widget type="Progress" skin="MW_EnergyBar_Red" position="13 146 65 12"
|
||||
align="Left Bottom" name="Health"/>
|
||||
<Widget type="Progress" skin="MW_EnergyBar_Blue" position="13 161 65 12"
|
||||
align="Left Bottom" name="Magicka"/>
|
||||
<Widget type="Progress" skin="MW_EnergyBar_Green" position="13 176 65 12"
|
||||
align="Left Bottom" name="Stamina"/>
|
||||
|
||||
<!-- Equipped weapon box -->
|
||||
<Widget type="Widget" skin="HUD_Box" position="82 146 36 36"
|
||||
align="Left Bottom">
|
||||
<Widget type="StaticImage" skin="StaticImage" position="2 2 32 32" align="Left Top"
|
||||
name="WeapImage"/>
|
||||
</Widget>
|
||||
<Widget type="Progress" skin="MW_EnergyBar_Red" position="82 182 36 6"
|
||||
align="Left Bottom" name="WeapStatus"/>
|
||||
|
||||
<!-- Selected spell box -->
|
||||
<Widget type="Widget" skin="HUD_Box" position="122 146 36 36"
|
||||
align="Left Bottom">
|
||||
<Widget type="StaticImage" skin="StaticImage" position="2 2 32 32" align="Left Top"
|
||||
name="SpellImage"/>
|
||||
</Widget>
|
||||
<Widget type="Progress" skin="MW_EnergyBar_Red" position="122 182 36 6"
|
||||
align="Left Bottom" name="SpellStatus"/>
|
||||
|
||||
<!-- Spell effects box -->
|
||||
<Widget type="Widget" skin="HUD_Box" position="199 168 20 20"
|
||||
align="Right Bottom" name="EffectBox">
|
||||
<Widget type="StaticImage" skin="StaticImage" position="2 2 16 16" align="Left Bottom"
|
||||
name="Effect1"/>
|
||||
</Widget>
|
||||
|
||||
<!-- Map box -->
|
||||
<Widget type="Widget" skin="HUD_Box" position="223 123 65 65"
|
||||
align="Right Bottom">
|
||||
<Widget type="StaticImage" skin="StaticImage" position="2 2 61 61" align="Left Bottom"
|
||||
name="MiniMap"/>
|
||||
<Widget type="StaticImage" skin="StaticImage" position="17 18 32 32" align="Left Bottom"
|
||||
name="Compass"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</MyGUI>
|
12
media_mygui/openmw_layers.xml
Normal file
12
media_mygui/openmw_layers.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Layer">
|
||||
<Layer name="Scene" overlapped="false" peek="true"/>
|
||||
<Layer name="HUD" overlapped="false" peek="true"/>
|
||||
<Layer name="Windows" overlapped="true" peek="true"/>
|
||||
<Layer name="Journal" overlapped="false" peek="false"/>
|
||||
<Layer name="MainMenu" overlapped="false" peek="false"/>
|
||||
<Layer name="Console" overlapped="false" peek="false"/>
|
||||
<Layer name="Pointer" overlapped="false" peek="false"/>
|
||||
<Layer name="Statistic" overlapped="false" peek="false"/>
|
||||
</MyGUI>
|
19
media_mygui/openmw_text.skin.xml
Normal file
19
media_mygui/openmw_text.skin.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Skin">
|
||||
<Skin name = "DaedricText" size = "16 16">
|
||||
<Property key="FontName" value = "daedric" />
|
||||
<Property key="FontHeight" value = "18" />
|
||||
<Property key="AlignText" value = "ALIGN_DEFAULT" />
|
||||
<Property key="Colour" value = "1 1 1" />
|
||||
<BasisSkin type="SimpleText" offset = "0 0 16 16" align = "ALIGN_STRETCH"/>
|
||||
</Skin>
|
||||
|
||||
<Skin name = "DaedricText_orig" size = "16 16">
|
||||
<Property key="FontName" value = "daedric_orig" />
|
||||
<Property key="FontHeight" value = "18" />
|
||||
<Property key="AlignText" value = "ALIGN_DEFAULT" />
|
||||
<Property key="Colour" value = "1 1 1" />
|
||||
<BasisSkin type="SimpleText" offset = "0 0 16 16" align = "ALIGN_STRETCH"/>
|
||||
</Skin>
|
||||
</MyGUI>
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Skin">
|
||||
<!-- Defines the window background. Use a pure black image -->
|
||||
<Skin name = "MW_WindowBG" size = "8 8" texture = "black.png">
|
||||
<!-- Defines a pure black background -->
|
||||
<Skin name = "BlackBG" size = "8 8" texture = "black.png">
|
||||
<BasisSkin type="MainSkin" offset = "0 0 8 8">
|
||||
<State name="normal" offset = "0 0 8 8"/>
|
||||
</BasisSkin>
|
||||
|
@ -159,7 +159,11 @@
|
|||
</Skin>
|
||||
|
||||
<Skin name="HB_ALL" size="260 20">
|
||||
<Child type="Widget" skin="HB_MID" offset="2 2 256 16" align="ALIGN_TOP ALIGN_HSTRETCH"/>
|
||||
<Child type="Widget" skin="HB_MID" offset="2 2 256 16" align="ALIGN_TOP ALIGN_LEFT"/>
|
||||
<Child type="Widget" skin="HB_MID" offset="258 2 256 16" align="ALIGN_TOP ALIGN_LEFT"/>
|
||||
<Child type="Widget" skin="HB_MID" offset="514 2 256 16" align="ALIGN_TOP ALIGN_LEFT"/>
|
||||
<Child type="Widget" skin="HB_MID" offset="770 2 256 16" align="ALIGN_TOP ALIGN_LEFT"/>
|
||||
<Child type="Widget" skin="HB_MID" offset="1026 2 256 16" align="ALIGN_TOP ALIGN_LEFT"/>
|
||||
<Child type="Widget" skin="HB_TOP" offset="2 0 256 2" align="ALIGN_TOP ALIGN_HSTRETCH"/>
|
||||
<Child type="Widget" skin="HB_BOTTOM" offset="2 18 256 2" align="ALIGN_BOTTOM ALIGN_HSTRETCH"/>
|
||||
<Child type="Widget" skin="HB_LEFT" offset="0 2 2 16" align="ALIGN_TOP ALIGN_LEFT"/>
|
||||
|
@ -209,8 +213,7 @@
|
|||
<Property key="Colour" value = "0.8 0.8 0.8" />
|
||||
<Property key="ToStick" value = "true" />
|
||||
|
||||
<Child type="Widget" skin="MW_WindowBG" offset = "6 26 244 22" align = "ALIGN_STRETCH" name = "Client">
|
||||
</Child>
|
||||
<Child type="Widget" skin="BlackBG" offset = "6 26 244 22" align = "ALIGN_STRETCH" name = "Client"/>
|
||||
|
||||
<!-- Outer orders -->
|
||||
<Child type="Widget" skin="TB_T" offset="4 0 248 4" align="ALIGN_TOP ALIGN_HSTRETCH" name="Action">
|
|
@ -163,7 +163,7 @@ void ogre_moveCameraRel(float x, float y, float z);
|
|||
// Insert a raw RGBA image into the texture system.
|
||||
//void ogre_insertTexture(char *name, int width, int height, void *data);
|
||||
|
||||
void gui_setupGUI();
|
||||
|
||||
// Test
|
||||
void gui_setupGUI();
|
||||
void gui_toggleGui();
|
||||
void gui_setFpsText(char *str);
|
||||
|
|
|
@ -25,12 +25,13 @@
|
|||
// Callbacks to D code.
|
||||
|
||||
// Called once each frame
|
||||
extern "C" int32_t d_frameStarted(float time);
|
||||
extern "C" int32_t d_frameStarted(float time, int guiMode);
|
||||
|
||||
// Handle events
|
||||
extern "C" void d_handleKey(int keycode, uint32_t text);
|
||||
extern "C" void d_handleMouseMove(const OIS::MouseState *state);
|
||||
extern "C" void d_handleMouseButton(const OIS::MouseState *state, int32_t button);
|
||||
extern "C" void d_handleMouseButton(const OIS::MouseState *state,
|
||||
int32_t button);
|
||||
|
||||
// Frame listener, passed to Ogre. The only thing we use this for is
|
||||
// to capture input and pass control to D code.
|
||||
|
@ -52,7 +53,7 @@ public:
|
|||
mGUI->injectFrameEntered(evt.timeSinceLastFrame);
|
||||
|
||||
// Turn over control to the D code
|
||||
return d_frameStarted(evt.timeSinceLastFrame);
|
||||
return d_frameStarted(evt.timeSinceLastFrame, guiMode);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -98,8 +99,8 @@ public:
|
|||
*/
|
||||
if(guiMode)
|
||||
mGUI->injectMousePress(arg, id);
|
||||
else
|
||||
d_handleMouseButton(&arg.state, id);
|
||||
|
||||
d_handleMouseButton(&arg.state, id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,24 +1,204 @@
|
|||
MyGUI::WidgetPtr FPSText;
|
||||
|
||||
MyGUI::WindowPtr window;
|
||||
MyGUI::WindowPtr mwindow;
|
||||
|
||||
OIS::MouseState state;
|
||||
|
||||
extern "C" void gui_toggleGui()
|
||||
{
|
||||
if(guiMode == 1)
|
||||
{
|
||||
guiMode = 0;
|
||||
mGUI->hidePointer();
|
||||
if(mwindow)
|
||||
mwindow->setVisible(false);
|
||||
state = mMouse->getMouseState();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Restore the GUI mouse position. This is a hack because silly
|
||||
// OIS doesn't allow us to set the mouse position ourselves.
|
||||
*((OIS::MouseState*)&(mMouse->getMouseState())) = state;
|
||||
mGUI->injectMouseMove(state.X.abs, state.Y.abs, 0);
|
||||
|
||||
guiMode = 1;
|
||||
mGUI->showPointer();
|
||||
if(mwindow)
|
||||
mwindow->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void turnGuiOff(MyGUI::WidgetPtr sender)
|
||||
{
|
||||
guiMode = 0;
|
||||
mGUI->hidePointer();
|
||||
if(window)
|
||||
{
|
||||
window->destroySmooth();
|
||||
window = NULL;
|
||||
}
|
||||
if(mwindow)
|
||||
{
|
||||
mwindow->destroySmooth();
|
||||
mwindow = NULL;
|
||||
}
|
||||
guiMode = 1;
|
||||
gui_toggleGui();
|
||||
}
|
||||
|
||||
// Copied from MyGUI demo code, with a few modifications
|
||||
class Layout
|
||||
{
|
||||
public:
|
||||
Layout(const std::string & _layout, MyGUI::WidgetPtr _parent = nullptr)
|
||||
: mMainWidget(nullptr)
|
||||
{
|
||||
initialise(_layout, _parent);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void getWidget(T * & _widget, const std::string & _name, bool _throw = true)
|
||||
{
|
||||
_widget = nullptr;
|
||||
for (MyGUI::VectorWidgetPtr::iterator iter=mListWindowRoot.begin();
|
||||
iter!=mListWindowRoot.end(); ++iter)
|
||||
{
|
||||
MyGUI::WidgetPtr find = (*iter)->findWidget(mPrefix + _name);
|
||||
if (nullptr != find)
|
||||
{
|
||||
T * cast = find->castType<T>(false);
|
||||
if (nullptr != cast)
|
||||
_widget = cast;
|
||||
else if (_throw)
|
||||
{
|
||||
MYGUI_EXCEPT("Error cast : dest type = '" << T::getClassTypeName()
|
||||
<< "' source name = '" << find->getName()
|
||||
<< "' source type = '" << find->getTypeName() << "' in layout '" << mLayoutName << "'");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
MYGUI_ASSERT( ! _throw, "widget name '" << _name << "' in layout '" << mLayoutName << "' not found.");
|
||||
}
|
||||
|
||||
void initialise(const std::string & _layout,
|
||||
MyGUI::WidgetPtr _parent = nullptr)
|
||||
{
|
||||
const std::string MAIN_WINDOW = "_Main";
|
||||
mLayoutName = _layout;
|
||||
|
||||
if (mLayoutName.empty())
|
||||
mMainWidget = _parent;
|
||||
else
|
||||
{
|
||||
mPrefix = MyGUI::utility::toString(this, "_");
|
||||
mListWindowRoot = MyGUI::LayoutManager::getInstance().loadLayout(mLayoutName, mPrefix, _parent);
|
||||
|
||||
const std::string main_name = mPrefix + MAIN_WINDOW;
|
||||
for (MyGUI::VectorWidgetPtr::iterator iter=mListWindowRoot.begin(); iter!=mListWindowRoot.end(); ++iter) {
|
||||
if ((*iter)->getName() == main_name)
|
||||
{
|
||||
mMainWidget = (*iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
MYGUI_ASSERT(mMainWidget, "root widget name '" << MAIN_WINDOW << "' in layout '" << mLayoutName << "' not found.");
|
||||
}
|
||||
}
|
||||
|
||||
void shutdown()
|
||||
{
|
||||
for (VectorBasePtr::iterator iter=mListBase.begin(); iter!=mListBase.end(); ++iter) {
|
||||
delete (*iter);
|
||||
}
|
||||
mListBase.clear();
|
||||
|
||||
MyGUI::LayoutManager::getInstance().unloadLayout(mListWindowRoot);
|
||||
mListWindowRoot.clear();
|
||||
}
|
||||
|
||||
void setCoord(int x, int y, int w, int h)
|
||||
{
|
||||
mMainWidget->setCoord(x,y,w,h);
|
||||
}
|
||||
|
||||
virtual ~Layout()
|
||||
{
|
||||
shutdown();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
MyGUI::WidgetPtr mMainWidget;
|
||||
|
||||
std::string mPrefix;
|
||||
std::string mLayoutName;
|
||||
MyGUI::VectorWidgetPtr mListWindowRoot;
|
||||
typedef std::vector<Layout*> VectorBasePtr;
|
||||
VectorBasePtr mListBase;
|
||||
};
|
||||
|
||||
class HUD : public Layout
|
||||
{
|
||||
public:
|
||||
HUD()
|
||||
: Layout("openmw_hud_layout.xml")
|
||||
{
|
||||
setCoord(0,0,
|
||||
mWindow->getWidth(),
|
||||
mWindow->getHeight());
|
||||
|
||||
// Energy bars
|
||||
getWidget(health, "Health");
|
||||
getWidget(magicka, "Magicka");
|
||||
getWidget(stamina, "Stamina");
|
||||
|
||||
// Item and spell images and status bars
|
||||
getWidget(weapImage, "WeapImage");
|
||||
getWidget(weapStatus, "WeapStatus");
|
||||
getWidget(spellImage, "SpellImage");
|
||||
getWidget(spellStatus, "SpellStatus");
|
||||
|
||||
getWidget(effectBox, "EffectBox");
|
||||
getWidget(effect1, "Effect1");
|
||||
|
||||
getWidget(minimap, "MiniMap");
|
||||
getWidget(compass, "Compass");
|
||||
|
||||
compass->setImageTexture("compass.dds");
|
||||
}
|
||||
|
||||
void setStats(int h, int hmax, int m, int mmax, int s, int smax)
|
||||
{
|
||||
health->setProgressRange(hmax);
|
||||
health->setProgressPosition(h);
|
||||
magicka->setProgressRange(mmax);
|
||||
magicka->setProgressPosition(m);
|
||||
stamina->setProgressRange(smax);
|
||||
stamina->setProgressPosition(s);
|
||||
}
|
||||
|
||||
void setWeapIcon(const char *str)
|
||||
{ weapImage->setImageTexture(str); }
|
||||
void setSpellIcon(const char *str)
|
||||
{ spellImage->setImageTexture(str); }
|
||||
|
||||
void setWeapStatus(int s, int smax)
|
||||
{
|
||||
weapStatus->setProgressRange(smax);
|
||||
weapStatus->setProgressPosition(s);
|
||||
}
|
||||
void setSpellStatus(int s, int smax)
|
||||
{
|
||||
spellStatus->setProgressRange(smax);
|
||||
spellStatus->setProgressPosition(s);
|
||||
}
|
||||
|
||||
void setEffect(const char *img)
|
||||
{ effect1->setImageTexture(img); }
|
||||
|
||||
MyGUI::ProgressPtr health, magicka, stamina;
|
||||
|
||||
MyGUI::StaticImagePtr weapImage, spellImage;
|
||||
MyGUI::ProgressPtr weapStatus, spellStatus;
|
||||
|
||||
MyGUI::WidgetPtr effectBox;
|
||||
MyGUI::StaticImagePtr effect1;
|
||||
|
||||
MyGUI::StaticImagePtr minimap;
|
||||
MyGUI::StaticImagePtr compass;
|
||||
};
|
||||
|
||||
HUD *hud;
|
||||
|
||||
extern "C" void gui_setupGUI()
|
||||
{
|
||||
ResourceGroupManager::getSingleton().
|
||||
|
@ -41,69 +221,66 @@ extern "C" void gui_setupGUI()
|
|||
"Statistic");
|
||||
FPSText->setTextAlign(MyGUI::ALIGN_RIGHT);
|
||||
FPSText->setNeedMouseFocus(false);
|
||||
FPSText->setTextColour(Ogre::ColourValue::White);
|
||||
|
||||
guiMode = 1;
|
||||
MyGUI::WidgetPtr tmp;
|
||||
/*
|
||||
// TESTING WINDOW WITH BUTTON
|
||||
width = 300;
|
||||
height = 200;
|
||||
window = mGUI->createWidget<MyGUI::Window>
|
||||
("WindowCS",
|
||||
(mWidth-width)/4, (mHeight-height)/4, // Position
|
||||
width, height, // Size
|
||||
MyGUI::ALIGN_DEFAULT, "Overlapped");
|
||||
//window->setFontName("ManualFont");
|
||||
window->setCaption("GUI Demo");
|
||||
window->setAlpha(0.7);
|
||||
|
||||
width = 150;
|
||||
height = 30;
|
||||
tmp = window->createWidget<MyGUI::Button>
|
||||
("ButtonSmall",
|
||||
40, 100, // Position
|
||||
width, height, // Size
|
||||
MyGUI::ALIGN_LEFT | MyGUI::ALIGN_TOP,
|
||||
"QuitButton");
|
||||
tmp->setCaption("Press this button");
|
||||
tmp->eventMouseButtonClick = MyGUI::newDelegate(&turnGuiOff);
|
||||
*/
|
||||
|
||||
// TESTING MORROWIND SKIN
|
||||
width = 300;
|
||||
height = 190;
|
||||
// Window with Morrowind skin
|
||||
mwindow = mGUI->createWidget<MyGUI::Window>
|
||||
("MW_Window",
|
||||
(mWidth-width)/4, (mHeight-height)/4, // Position
|
||||
width, height, // Size
|
||||
MyGUI::ALIGN_DEFAULT, "Overlapped");
|
||||
300, 190, // Size
|
||||
MyGUI::ALIGN_DEFAULT, "Windows");
|
||||
mwindow->setCaption("Skin test");
|
||||
mwindow->setMinMax(100, 140, 1000, 1000);
|
||||
mwindow->setAlpha(1);
|
||||
mwindow->setMinSize(120, 140);
|
||||
mwindow->getClientWidget()->setAlpha(0.6);
|
||||
|
||||
width = 45;
|
||||
height = 24;
|
||||
MyGUI::WidgetPtr tmp;
|
||||
tmp = mwindow->createWidget<MyGUI::Button>
|
||||
("MW_Button",
|
||||
10, 32, // Position
|
||||
width, height, // Size
|
||||
45, 24, // Size
|
||||
MyGUI::ALIGN_LEFT | MyGUI::ALIGN_TOP,
|
||||
"MWButton1");
|
||||
tmp->setCaption("Close");
|
||||
tmp->eventMouseButtonClick = MyGUI::newDelegate(&turnGuiOff);
|
||||
tmp->setInheritsAlpha(false);
|
||||
|
||||
// TESTING BITMAP FONT
|
||||
/*
|
||||
tmp = mGUI->createWidget<MyGUI::Widget>
|
||||
("StaticText",
|
||||
10, mHeight - height, // Position
|
||||
width, height, // Size
|
||||
MyGUI::ALIGN_LEFT | MyGUI::ALIGN_BOTTOM,
|
||||
"Statistic");
|
||||
tmp->setTextAlign(MyGUI::ALIGN_LEFT);
|
||||
tmp->setFontName("ManualFont");
|
||||
tmp->setCaption("ABC");
|
||||
//*/
|
||||
tmp = mwindow->createWidget<MyGUI::StaticText>
|
||||
("DaedricText_orig",
|
||||
10,70,
|
||||
300, 20,
|
||||
MyGUI::ALIGN_LEFT | MyGUI::ALIGN_TOP,
|
||||
"Daed1");
|
||||
tmp->setCaption("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
|
||||
tmp = mwindow->createWidget<MyGUI::StaticText>
|
||||
("DaedricText",
|
||||
10,100,
|
||||
300, 20,
|
||||
MyGUI::ALIGN_LEFT | MyGUI::ALIGN_TOP,
|
||||
"Daed2");
|
||||
tmp->setCaption("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
|
||||
// Turn the GUI off at startup
|
||||
turnGuiOff(NULL);
|
||||
// Start the mouse in the middle of the screen
|
||||
state.X.abs = mWidth / 2;
|
||||
state.Y.abs = mHeight / 2;
|
||||
|
||||
MyGUI::ProgressPtr prog;
|
||||
|
||||
// Set up the HUD
|
||||
hud = new HUD();
|
||||
|
||||
hud->setStats(60, 100,
|
||||
30, 100,
|
||||
80, 100);
|
||||
|
||||
hud->setWeapIcon("icons\\w\\tx_knife_iron.dds");
|
||||
hud->setWeapStatus(90, 100);
|
||||
hud->setSpellIcon("icons\\s\\b_tx_s_rstor_health.dds");
|
||||
hud->setSpellStatus(65, 100);
|
||||
|
||||
hud->setEffect("icons\\s\\tx_s_chameleon.dds");
|
||||
}
|
||||
|
||||
extern "C" void gui_setFpsText(char *str)
|
||||
|
|
Loading…
Reference in a new issue