- Integrated MyGUI and made a small test case.

- Made a (very experimental) Morrowind skin
- Decoded the fnt/tex font files, but they aren't used yet


git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@84 ea6a568a-9f4f-0410-981a-c910a81bb256
pull/7/head
nkorslund 16 years ago
parent 6dcf6c565a
commit 17a2c67d26

@ -1,15 +1,15 @@
# Designed for GNU Make
# Compiler settings
CXXFLAGS?= -Wall -g
CXXFLAGS?= -g
DMD=gdmd -version=Posix
#DMD=dmd -version=Posix
# Some extra flags for niftool and bsatool
NIFFLAGS=-debug=warnstd -debug=check -debug=statecheck -debug=strict -debug=verbose
# Compiler settings for Ogre + OIS.
CF_OIS=$(shell pkg-config --cflags OIS OGRE)
# Compiler settings for Ogre, OIS and MyGUI
CF_OIS=$(shell pkg-config --cflags OIS OGRE MyGUI)
OGCC=$(CXX) $(CXXFLAGS) $(CF_OIS)
# Compiler settings for ffmpeg.
@ -22,7 +22,7 @@ BGCC=$(CXX) $(CXXFLAGS) $(CF_BULLET)
# Ogre C++ files, on the form ogre/cpp_X.cpp. Only the first file is
# passed to the compiler, the rest are dependencies.
ogre_cpp=ogre framelistener interface overlay bsaarchive
ogre_cpp=ogre framelistener interface bsaarchive mygui
# FFmpeg files, in the form sound/cpp_X.cpp.
avcodec_cpp=avcodec
@ -82,10 +82,10 @@ nifobjs/%.o: %.d
$(DMD) $(NIFFLAGS) -c $< -of$@
openmw: openmw.d cpp_ogre.o cpp_avcodec.o cpp_bullet.o $(obj)
$(DMD) $^ -of$@ -L-lopenal -L-lOgreMain -L-lOIS -L-lavcodec -L-lavformat bullet/libbulletdynamics.a bullet/libbulletcollision.a bullet/libbulletmath.a
$(DMD) $^ -of$@ -L-lopenal -L-lOgreMain -L-lOIS -L-lmygui -L-luuid -L-lavcodec -L-lavformat bullet/libbulletdynamics.a bullet/libbulletcollision.a bullet/libbulletmath.a
esmtool: esmtool.d cpp_ogre.o cpp_avcodec.o cpp_bullet.o $(obj)
$(DMD) $^ -of$@ -L-lopenal -L-lOgreMain -L-lOIS -L-lavcodec -L-lavformat bullet/libbulletdynamics.a bullet/libbulletcollision.a bullet/libbulletmath.a
$(DMD) $^ -of$@ -L-lopenal -L-lOgreMain -L-lOIS -L-lmygui -L-luuid -L-lavcodec -L-lavformat bullet/libbulletdynamics.a bullet/libbulletcollision.a bullet/libbulletmath.a
niftool: niftool.d $(obj_nif)
$(DMD) $^ -of$@

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 B

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Font">
<Font name="MyGUI_CoreFont.18" source="Comic.TTF" size="18" resolution="72" antialias_colour="false" space_width="a" tab_count="4" spacer="5">
<Code range="33 126"/>
<Code range="1025 1105"/>
<Code range="8470 8470" help="№"/>
<Code hide="128"/>
<Code hide="1026 1039"/>
<Code hide="1104"/>
</Font>
</MyGUI>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Lang">
<Help name="name_language">
"unassigned, escape, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, -, =, backspace, tab, q, w, e, r, t, y, u, i, o, p, [, ], enter, lcontrol, a, s, d, f, g, h, j, k, l, ;, ', `, lshift, \, z, x, c, v, b, n, m, comma, ., /, rshift, * on numeric keypad, leftalt, space,
unassigned, escape, !, @, #, $, %, ^, &, *, (, ), _, +, backspace, tab, Q, W, E, R, T, Y, U, I, O, P, {, }, enter, lcontrol, A, S, D, F, G, H, J, K, L, :, double quotes, ~, lshift, |, Z, X, C, V, B, N, M, <, >, ?, rshift, * on numeric keypad, leftalt, space"
</Help>
<Lang name="Russian">
0, 0, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 45, 61, 0, 0, 1081, 1094, 1091, 1082, 1077, 1085, 1075, 1096, 1097, 1079, 1093, 1098, 0, 0, 1092, 1099, 1074, 1072, 1087, 1088, 1086, 1083, 1076, 1078, 1101, 1105, 0, 92, 1103, 1095, 1089, 1084, 1080, 1090, 1100, 1073, 1102, 46, 0, 42, 0, 32,
0, 0, 33, 34, 8470, 59, 37, 58, 63, 42, 40, 41, 95, 43, 0, 0, 1049, 1062, 1059, 1050, 1045, 1053, 1043, 1064, 1065, 1047, 1061, 1066, 0, 0, 1060, 1067, 1042, 1040, 1055, 1056, 1054, 1051, 1044, 1046, 1069, 1025, 0, 47, 1071, 1063, 1057, 1052, 1048, 1058, 1068, 1041, 1070, 44, 0, 42, 0, 32
</Lang>
</MyGUI>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layer">
<Layer name="Back" overlapped="false" peek="true"/>
<Layer name="Overlapped" overlapped="true" peek="true"/>
<Layer name="Middle" overlapped="false" peek="true"/>
<Layer name="Modal" overlapped="true" peek="true"/>
<Layer name="Main" overlapped="false" peek="true"/>
<Layer name="Popup" overlapped="true" peek="true"/>
<Layer name="FadeMiddle" overlapped="false" peek="false"/>
<Layer name="Info" overlapped="true" peek="true"/>
<Layer name="Tooltip"overlapped="false" peek="true"/>
<Layer name="DragAndDrop"overlapped="false" peek="false"/>
<Layer name="FadeBusy" overlapped="false" peek="false"/>
<Layer name="Pointer" overlapped="false" peek="false"/>
<Layer name="Fade" overlapped="false" peek="false"/>
<Layer name="Statistic" overlapped="false" peek="false"/>
</MyGUI>

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Pointer">
<Pointer layer="Pointer" texture="core.png" default="arrow">
<Info name="arrow" point="1 1" size="32 32" offset="0 224 32 32"/>
<Info name="beam" point="16 16" size="32 32" offset="32 224 32 32"/>
<Info name="size_left" point="16 16" size="32 32" offset="64 224 32 32"/>
<Info name="hand" point="16 16" size="32 32" offset="96 224 32 32"/>
</Pointer>
</MyGUI>

File diff suppressed because it is too large Load Diff

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI>
<MyGUI type="List">
<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.pointer" group="General"/>
<List file="core.plugin"/>
<List file="openmw_windows.skin" group="General"/>
</MyGUI>
</MyGUI>

@ -0,0 +1,218 @@
<?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">
<BasisSkin type="MainSkin" offset = "0 0 8 8">
<State name="normal" offset = "0 0 8 8"/>
</BasisSkin>
</Skin>
<!-- These define the window borders -->
<Skin name="TB_B" size="512 4" texture="menu_thick_border_bottom.dds">
<Property key="Pointer" value = "size_left" />
<BasisSkin type="MainSkin" offset = "0 0 512 4">
<State name="normal" offset = "0 0 512 4"/>
</BasisSkin>
</Skin>
<Skin name="TB_R" size="4 512" texture="menu_thick_border_right.dds">
<Property key="Pointer" value = "size_left" />
<BasisSkin type="MainSkin" offset = "0 0 4 512">
<State name="normal" offset = "0 0 4 512"/>
</BasisSkin>
</Skin>
<Skin name="TB_T" size="512 4" texture="menu_thick_border_top.dds">
<Property key="Pointer" value = "size_left" />
<BasisSkin type="MainSkin" offset = "0 0 512 4">
<State name="normal" offset = "0 0 512 4"/>
</BasisSkin>
</Skin>
<Skin name="TB_L" size="4 512" texture="menu_thick_border_left.dds">
<Property key="Pointer" value = "size_left" />
<BasisSkin type="MainSkin" offset = "0 0 4 512">
<State name="normal" offset = "0 0 4 512"/>
</BasisSkin>
</Skin>
<!-- Window border corners -->
<Skin name="TB_BR" size="4 4" texture="menu_thick_border_bottom_right_corner.dds">
<Property key="Pointer" value = "size_left" />
<BasisSkin type="MainSkin" offset = "0 0 4 4">
<State name="normal" offset = "0 0 4 4"/>
</BasisSkin>
</Skin>
<Skin name="TB_BL" size="4 4" texture="menu_thick_border_bottom_left_corner.dds">
<Property key="Pointer" value = "size_left" />
<BasisSkin type="MainSkin" offset = "0 0 4 4">
<State name="normal" offset = "0 0 4 4"/>
</BasisSkin>
</Skin>
<Skin name="TB_TR" size="4 4" texture="menu_thick_border_top_right_corner.dds">
<Property key="Pointer" value = "size_left" />
<BasisSkin type="MainSkin" offset = "0 0 4 4">
<State name="normal" offset = "0 0 4 4"/>
</BasisSkin>
</Skin>
<Skin name="TB_TL" size="4 4" texture="menu_thick_border_top_left_corner.dds">
<Property key="Pointer" value = "size_left" />
<BasisSkin type="MainSkin" offset = "0 0 4 4">
<State name="normal" offset = "0 0 4 4"/>
</BasisSkin>
</Skin>
<!-- These parts defines the 'blocks' to the left and right of the caption -->
<Skin name="HB_MID" size="256 16" texture="menu_head_block_middle.dds">
<BasisSkin type="MainSkin" offset = "0 0 256 16">
<State name="normal" offset = "0 0 256 16"/>
</BasisSkin>
</Skin>
<Skin name="HB_TOP" size="256 2" texture="menu_head_block_top.dds">
<BasisSkin type="MainSkin" offset = "0 0 256 2">
<State name="normal" offset = "0 0 256 2"/>
</BasisSkin>
</Skin>
<Skin name="HB_BOTTOM" size="256 2" texture="menu_head_block_bottom.dds">
<BasisSkin type="MainSkin" offset = "0 0 256 2">
<State name="normal" offset = "0 0 256 2"/>
</BasisSkin>
</Skin>
<Skin name="HB_LEFT" size="2 16" texture="menu_head_block_left.dds">
<BasisSkin type="MainSkin" offset = "0 0 2 16">
<State name="normal" offset = "0 0 2 16"/>
</BasisSkin>
</Skin>
<Skin name="HB_RIGHT" size="2 16" texture="menu_head_block_right.dds">
<BasisSkin type="MainSkin" offset = "0 0 2 16">
<State name="normal" offset = "0 0 2 16"/>
</BasisSkin>
</Skin>
<Skin name="HB_TR" size="2 2" texture="menu_head_block_top_right_corner.dds">
<BasisSkin type="MainSkin" offset = "0 0 2 2">
<State name="normal" offset = "0 0 2 2"/>
</BasisSkin>
</Skin>
<Skin name="HB_TL" size="2 2" texture="menu_head_block_top_left_corner.dds">
<BasisSkin type="MainSkin" offset = "0 0 2 2">
<State name="normal" offset = "0 0 2 2"/>
</BasisSkin>
</Skin>
<Skin name="HB_BR" size="2 2" texture="menu_head_block_bottom_right_corner.dds">
<BasisSkin type="MainSkin" offset = "0 0 2 2">
<State name="normal" offset = "0 0 2 2"/>
</BasisSkin>
</Skin>
<Skin name="HB_BL" size="2 2" texture="menu_head_block_bottom_left_corner.dds">
<BasisSkin type="MainSkin" offset = "0 0 2 2">
<State name="normal" offset = "0 0 2 2"/>
</BasisSkin>
</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>
<Child type="Widget" skin="HB_TOP" offset="2 0 256 2" align="ALIGN_TOP ALIGN_HSTRETCH"></Child>
<Child type="Widget" skin="HB_BOTTOM" offset="2 18 256 2" align="ALIGN_BOTTOM ALIGN_HSTRETCH"></Child>
<Child type="Widget" skin="HB_LEFT" offset="0 2 2 16" align="ALIGN_TOP ALIGN_LEFT"></Child>
<Child type="Widget" skin="HB_RIGHT" offset="258 2 2 16" align="ALIGN_TOP ALIGN_RIGHT"></Child>
<Child type="Widget" skin="HB_TR" offset="258 0 2 2" align="ALIGN_TOP ALIGN_RIGHT"></Child>
<Child type="Widget" skin="HB_TL" offset="0 0 2 2" align="ALIGN_TOP ALIGN_LEFT"></Child>
<Child type="Widget" skin="HB_BR" offset="258 18 2 2" align="ALIGN_BOTTOM ALIGN_RIGHT"></Child>
<Child type="Widget" skin="HB_BL" offset="0 18 2 2" align="ALIGN_BOTTOM ALIGN_LEFT"></Child>
</Skin>
<!-- The actual caption. It contains the edges of each of the blocks on
its sides as well -->
<Skin name = "MW_Caption" size = "88 20" texture = "black.png" >
<Property key="FontName" value = "MyGUI_CoreFont.18" />
<Property key="FontHeight" value = "18" />
<Property key="AlignText" value = "ALIGN_CENTER" />
<Property key="Colour" value = "0.36 0.62 0.75" />
<BasisSkin type="SubSkin" offset="0 0 88 20" align="ALIGN_STRETCH">
<State name="normal" offset = "0 0 8 8"/>
</BasisSkin>
<BasisSkin type="SimpleText" offset = "2 0 84 20" align = "ALIGN_STRETCH"/>
<!-- Add the borders of the surrounding blocks -->
<Child type="Widget" skin="HB_LEFT" offset="86 2 2 16" align="ALIGN_TOP ALIGN_RIGHT"></Child>
<Child type="Widget" skin="HB_RIGHT" offset="0 2 2 16" align="ALIGN_TOP ALIGN_LEFT"></Child>
<Child type="Widget" skin="HB_TR" offset="0 0 2 2" align="ALIGN_TOP ALIGN_LEFT"></Child>
<Child type="Widget" skin="HB_TL" offset="86 0 2 2" align="ALIGN_TOP ALIGN_RIGHT"></Child>
<Child type="Widget" skin="HB_BR" offset="0 18 2 2" align="ALIGN_BOTTOM ALIGN_LEFT"></Child>
<Child type="Widget" skin="HB_BL" offset="86 18 2 2" align="ALIGN_BOTTOM ALIGN_RIGHT"></Child>
</Skin>
<Skin name = "MW_Window" size = "256 54">
<Property key="FontName" value = "MyGUI_CoreFont.18" />
<Property key="FontHeight" value = "18" />
<Property key="AlignText" value = "ALIGN_CENTER" />
<Property key="Colour" value = "0 0 0" />
<Property key="ToStick" value = "true" />
<Child type="Widget" skin="MW_WindowBG" offset = "4 24 248 26" align = "ALIGN_STRETCH" name = "Client">
</Child>
<!-- Outer orders -->
<Child type="Widget" skin="TB_T" offset="4 0 248 4" align="ALIGN_TOP ALIGN_HSTRETCH" name="Action">
<Property key="Scale" value = "0 1 0 -1"/>
</Child>
<Child type="Widget" skin="TB_L" offset="0 4 4 46" align="ALIGN_LEFT ALIGN_VSTRETCH" name="Action">
<Property key="Scale" value = "1 0 -1 0"/>
</Child>
<Child type="Widget" skin="TB_B" offset="4 50 248 4" align="ALIGN_BOTTOM ALIGN_HSTRETCH" name="Action">
<Property key="Scale" value = "0 0 0 1"/>
</Child>
<Child type="Widget" skin="TB_R" offset="252 4 4 46" align="ALIGN_RIGHT ALIGN_VSTRETCH" name="Action">
<Property key="Scale" value = "0 0 1 0"/>
</Child>
<Child type="Widget" skin="TB_BR" offset="252 50 4 4" align="ALIGN_RIGHT ALIGN_BOTTOM" name="Action">
<Property key="Scale" value = "0 0 1 1"/>
</Child>
<Child type="Widget" skin="TB_BL" offset="0 50 4 4" align="ALIGN_LEFT ALIGN_BOTTOM" name="Action">
<Property key="Scale" value = "1 0 -1 1"/>
</Child>
<Child type="Widget" skin="TB_TR" offset="252 0 4 4" align="ALIGN_RIGHT ALIGN_TOP" name="Action">
<Property key="Scale" value = "0 1 1 -1"/>
</Child>
<Child type="Widget" skin="TB_TL" offset="0 0 4 4" align="ALIGN_LEFT ALIGN_TOP" name="Action">
<Property key="Scale" value = "1 1 -1 -1"/>
</Child>
<!-- Inner borders -->
<!-- Caption -->
<Child type="Widget" skin="HB_ALL" offset="4 4 248 20" align = "ALIGN_TOP ALIGN_HSTRETCH">
<Property key="Scale" value = "1 1 0 0"/>
</Child>
<Child type="Widget" skin="MW_Caption" offset = "80 4 88 20" align = "ALIGN_HCENTER ALIGN_TOP" name = "Caption">
</Child>
<!-- This invisible button makes it possible to move the
window by dragging the caption. -->
<Child type="Button" offset="4 4 248 20" align="ALIGN_HSTRETCH ALIGN_TOP" name="Action">
<Property key="Scale" value = "1 1 0 0"/>
</Child>
<!--
<Child type="Button" skin="WindowCaption" offset = "5 50 10 30" align = "ALIGN_HSTRETCH ALIGN_TOP" name = "Caption">
<Property key="Scale" value = "1 1 0 0"/>
</Child>
<Child type="Button" skin="WindowX" offset = "20 80 24 30" align = "ALIGN_LEFT ALIGN_TOP" name = "Button">
<Property key="Event" value = "close"/>
</Child>
-->
</Skin>
</MyGUI>

@ -4,7 +4,7 @@
[openmw.d]
# Add libraries and the two C++ object files
buildflags = -llOgreMain -llopenal -llOIS -llavcodec -llavformat cpp_ogre.o cpp_avcodec.o cpp_bullet.o bullet/libbulletdynamics.a bullet/libbulletcollision.a bullet/libbulletmath.a
buildflags = -llmygui -llOgreMain -llopenal -llOIS -lluuid -llavcodec -llavformat cpp_ogre.o cpp_avcodec.o cpp_bullet.o bullet/libbulletdynamics.a bullet/libbulletcollision.a bullet/libbulletmath.a
# Make sure the C++ object files are built first
version(Windows) {
@ -18,7 +18,6 @@ prebuild += dsss clean niftool
###########################
# Bsa inspection tool #
###########################
@ -34,7 +33,7 @@ prebuild += dsss clean niftool
[esmtool.d]
# Because of interdepencies between the ESM code and the resource
# manager, we have to include all the C++ stuff.
buildflags = -llOgreMain -llopenal -llOIS -llavcodec -llavformat cpp_ogre.o cpp_avcodec.o cpp_bullet.o bullet/libbulletdynamics.a bullet/libbulletcollision.a bullet/libbulletmath.a
buildflags = -llmygui -llOgreMain -llopenal -llOIS -lluuid -llavcodec -llavformat cpp_ogre.o cpp_avcodec.o cpp_bullet.o bullet/libbulletdynamics.a bullet/libbulletcollision.a bullet/libbulletmath.a
@ -48,3 +47,5 @@ buildflags = -debug=warnstd -debug=check -debug=statecheck -debug=strict -debug=
prebuild = dsss clean niftool
[bored.d]

@ -0,0 +1,146 @@
/*
Font loader for the Morrowind .FNT/.TEX font file pair. The current
code has just been used for testing purposes and to decode the file
format. To make it work with MyGUI, we will have to cooperate with a
custom sub-class of the MyGUI::Font class in C++.
*/
module fonts.fntfile;
import std.stream;
import monster.util.string;
align(1)
struct FntEntry
{
// Positions, as fractions of the entire texture surface. The
// xstart2 etc values are just repeated information. The reason for
// this is that the characters are stored as four points, with an
// (x,y) coordinate each. Since all the rectangles are aligned with
// the image however, this is pretty redundant information.
float xstart, ystart;
float xend;
float ystart2, xstart2;
float yend;
float xend2, yend2;
float width;
float height;
int zero1; // Empty heigth? (always zero)
float emptyWidth; // Width for empty characters
float unk2; // Vertical displacement?
int zero2; // Horizontal displacement?
bool isUsed() { return width != 0; }
}
static assert(FntEntry.sizeof == 56);
align(1)
struct FntFile
{
float size;
int unk2, unk3;
char[128] texname;
ubyte[160] filler; // Makes the header exactly 300 bytes long
FntEntry[255] chars;
}
align(1)
union Color
{
ubyte[4] rgba;
uint val;
}
static assert(Color.sizeof == 4);
// One character
struct Char
{
Color[][] pixels;
bool isUsed;
int width, height;
char chr;
}
FntFile fnt;
Char[255] chars;
// Load a fnt-file
void loadFont(char[] fntFile)
{
assert(iEnds(fntFile, ".fnt"),
"loadFont() can only load .fnt files");
File s = new File(fntFile);
s.readExact(&fnt, fnt.sizeof);
s.close();
// Load the .tex file
int texWidth, texHeight;
char[] tfile = stripz(fnt.texname)~".tex";
// DIRTY hack since we can't do case-insensitive file searching yet
if(tfile[0] == 'D') tfile[0] = 'd';
s.open(tfile);
s.read(texWidth);
s.read(texHeight);
assert(s.size() == 4*(texWidth*texHeight + 2));
ubyte[] buf;
buf.length = s.size - s.position;
s.readExact(buf.ptr, buf.length);
delete s;
// Get the pixel buffer as a series of ints
uint[] pixelBuf = cast(uint[]) buf;
foreach(i, ch; fnt.chars)
with(chars[i])
{
// Store the char, if it is printable
if(i > 33 && i < 127)
chr = i;
else chr = ' ';
// Store the pixel dimensions
isUsed = ch.isUsed;
height = cast(int)ch.height;
if(isUsed)
width = cast(int)ch.width;
else
width = cast(int)ch.emptyWidth;
assert(ch.emptyWidth == 0 || ch.emptyWidth == -1 || !isUsed);
assert(ch.zero1 == 0);
assert(ch.zero2 == 0);
assert(ch.xstart2 == ch.xstart);
assert(ch.ystart2 == ch.ystart);
assert(ch.xend2 == ch.xend);
assert(ch.yend2 == ch.yend);
// If the character is not present, skip to the next one now.
if(!isUsed) continue;
// Get the pixel coordinates of this character
int startX = cast(int) (ch.xstart * texWidth);
int startY = cast(int) (ch.ystart * texHeight);
int endX = cast(int) (ch.xend * texWidth);
int endY = cast(int) (ch.yend * texHeight);
assert(endX-startX == width);
assert(endY-startY == height);
// Set up the pixel array
pixels.length = height;
foreach(line, ref slice; pixels)
{
// First pixel in the line
int strt = texWidth*(startY+line) + startX;
// Get a slice of the pixel data
slice = cast(Color[])pixelBuf[strt..strt+width];
}
}
}

@ -187,7 +187,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.Debug: ogre_debug(0); break;
case Keys.Debug: break;
case Keys.ScreenShot: takeScreenShot(); break;
case Keys.Pause: togglePause(); break;
case Keys.Exit: exitProgram(); break;

@ -1,29 +1,38 @@
// Small script that prints the FPS to screen with regular intervals.
class FPSTicker;
import frames;
// Sleep one frame. This makes sure that we won't start running until
// the rendering begins. Not critically important, but it prevents the
// first printed value from being 'nan'.
fsleep(1);
// Set the FPS widget text
native setText(char[][] args...);
// counter and totalTime (in the 'frames' module) are updated
// automatically by the system.
ulong lastFrame = counter;
float lastTime = totalTime;
run()
{
// Sleep one frame. This makes sure that we won't start running until
// the rendering begins. Not critically important, but it prevents the
// first printed value from being 'nan'.
fsleep(1);
float delay = 1.5;
setText("hello!");
while(true)
{
sleep(delay);
// counter and totalTime (in the 'frames' module) are updated
// automatically by the system.
ulong lastFrame = counter;
float lastTime = totalTime;
float delay = 1.5;
while(true)
{
sleep(delay);
// Calculate differences since last frame
ulong fdiff = counter-lastFrame;
float tdiff = totalTime-lastTime;
// Calculate differences since last frame
ulong fdiff = counter-lastFrame;
float tdiff = totalTime-lastTime;
print("fps:", fdiff / tdiff);
setText("fps: ", fdiff / tdiff);
lastFrame = counter;
lastTime = totalTime;
lastFrame = counter;
lastTime = totalTime;
}
}

@ -28,6 +28,9 @@ import monster.compiler.scopes : global;
import monster.modules.timer;
import core.config;
import ogre.bindings;
import std.string;
// Set up the base Monster classes we need in OpenMW
void initMonsterScripts()
@ -48,8 +51,23 @@ void initMonsterScripts()
config.mo = (new MonsterClass("Config")).getSing();
// Run the fps ticker
vm.run("fpsticker.mn");
//vm.run("fpsticker.mn");
auto mc = new MonsterClass("fpsticker.mn");
mc.bind("setText", &setFpsText);
mc.createObject().call("run");
// Run the test script
vm.run("test.mn");
}
void setFpsText()
{
AIndex[] args = stack.popAArray();
char[] res;
foreach(AIndex ind; args)
res ~= format("%s", arrays.getRef(ind).carr);
gui_setFpsText(res.ptr);
}

@ -160,5 +160,5 @@ void ogre_getCameraPos(float *x, float *y, float *z);
void ogre_getCameraOrientation(float *fx, float *fy, float *fz, float *ux, float *uy, float *uz);
void ogre_moveCameraRel(float x, float y, float z);
// Do some debug action. Check the menu for today's specials!
void ogre_debug(int i);
// Test
void gui_setFpsText(char *str);

@ -97,16 +97,33 @@ public:
}
// Gets called once for each of the ogre formats, *.program,
// *.material etc. We can ignore this.
// *.material etc. It's also called by MyGUI to find textures, so we
// have to channel it through exists().
FileInfoListPtr findFileInfo(const String& pattern, bool recursive = true,
bool dirs = false)
{
//std::cout << "findFileInfo(" << pattern << ", " << recursive
// << ", " << dirs << ")\n";
/*
std::cout << "findFileInfo(" << pattern << ", " << recursive
<< ", " << dirs << ")\n";
*/
FileInfoListPtr ptr = FileInfoListPtr(new FileInfoList());
//std::cout << "BSAArchive::findFileInfo is not implemented!\n";
// Check if the file exists (only works for single files - wild
// cards and recursive search isn't implemented.)
if(exists(pattern))
{
FileInfo fi;
fi.archive = this;
fi.filename = pattern;
fi.path = "";
// It apparently doesn't matter that we return bogus
// information
fi.compressedSize = fi.uncompressedSize = 0;
ptr->push_back(fi);
}
return ptr;
}

@ -48,6 +48,10 @@ public:
mKeyboard->capture();
mMouse->capture();
// Notify the GUI
mGUI->injectFrameEntered(evt.timeSinceLastFrame);
// Turn over control to the D code
return d_frameStarted(evt.timeSinceLastFrame);
}
};
@ -75,7 +79,12 @@ public:
<< s.X.abs << ", " << s.Y.abs << ", " << s.Z.abs << ") Rel("
<< s.X.rel << ", " << s.Y.rel << ", " << s.Z.rel << ")\n";
*/
d_handleMouseMove(&arg.state);
// TODO: this should be handled elsewhere later on, most likely in
// Monster script.
if(guiMode)
mGUI->injectMouseMove(arg);
else
d_handleMouseMove(&arg.state);
return true;
}
@ -87,13 +96,22 @@ public:
<< s.X.abs << ", " << s.Y.abs << ", " << s.Z.abs << ") Rel("
<< s.X.rel << ", " << s.Y.rel << ", " << s.Z.rel << ")\n";
*/
d_handleMouseButton(&arg.state, id);
if(guiMode)
mGUI->injectMousePress(arg, id);
else
d_handleMouseButton(&arg.state, id);
return true;
}
bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
if(guiMode)
mGUI->injectMouseRelease(arg, id);
return true;
}
// Unused
bool keyReleased( const OIS::KeyEvent &arg ) { return true; }
bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) { return true; }
};
MorroFrameListener mFrameListener;

@ -147,14 +147,10 @@ extern "C" void ogre_initWindow()
mMouse = static_cast<Mouse*>(mInputManager->createInputObject
( OISMouse, bufferedMouse ));
unsigned int width, height, depth;
int left, top;
mWindow->getMetrics(width, height, depth, left, top);
// Set mouse region
const MouseState &ms = mMouse->getMouseState();
ms.width = width;
ms.height = height;
ms.width = mWindow->getWidth();
ms.height = mWindow->getHeight();
// Register the input listener
mKeyboard -> setEventCallback( &mInput );
@ -207,6 +203,9 @@ extern "C" void ogre_makeScene()
g_light->setDiffuseColour(1,0.7,0.3);
g_light->setAttenuation(2000, 0, 0.008, 0);
*/
// Finally, set up the GUI
setupGUI();
}
/*
@ -447,9 +446,6 @@ public:
}
} dummyLoader;
// TODO/FIXME/DEBUG (MURDER/DEATH/KILL)
String LASTNAME;
// Load the contents of a mesh
extern "C" void ogre_createMesh(
char* name, // Name of the mesh
@ -652,9 +648,6 @@ extern "C" void ogre_createMaterial(char *name, // Name to give
// like crap so it's not enabled right now.
//material->setSceneBlending(SBT_TRANSPARENT_ALPHA);
// Temporary, just to store the name of one valid material.
LASTNAME = material->getName();
}
extern "C" SceneNode *ogre_getDetachedNode()

@ -0,0 +1,104 @@
MyGUI::WidgetPtr FPSText;
MyGUI::WindowPtr window;
MyGUI::WindowPtr mwindow;
void turnGuiOff(MyGUI::WidgetPtr sender)
{
guiMode = 0;
mGUI->hidePointer();
if(window)
{
window->destroySmooth();
window = NULL;
}
if(mwindow)
{
mwindow->destroySmooth();
mwindow = NULL;
}
}
void setupGUI()
{
ResourceGroupManager::getSingleton().
addResourceLocation("MyGUI_Media", "FileSystem", "General");
mGUI = new MyGUI::Gui();
mGUI->initialise(mWindow);
int mWidth = mWindow->getWidth();
int mHeight = mWindow->getHeight();
int width = 120;
int height = 30;
// FPS Ticker
FPSText = mGUI->createWidget<MyGUI::Widget>
("StaticText",
mWidth - width -10, 10, // Position
width, height, // Size
MyGUI::ALIGN_RIGHT | MyGUI::ALIGN_TOP,
"Statistic");
FPSText->setTextAlign(MyGUI::ALIGN_RIGHT);
FPSText->setColour(Ogre::ColourValue::White);
FPSText->setNeedMouseFocus(false);
// TESTING WINDOW WITH BUTTON
guiMode = 1;
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->setColour(Ogre::ColourValue::White);
//window->setFontName("ManualFont");
window->setCaption("GUI Demo");
window->setMinMax(180, 160, 1000, 1000);
window->setAlpha(0.7);
width = 150;
height = 30;
MyGUI::WidgetPtr tmp;
tmp = window->createWidget<MyGUI::Button>
("ButtonSmall",
40, 100, // Position
width, height, // Size
MyGUI::ALIGN_LEFT | MyGUI::ALIGN_TOP,
"Main");
tmp->setCaption("Press this button");
tmp->eventMouseButtonClick = MyGUI::newDelegate(&turnGuiOff);
// TESTING MORROWIND SKIN
width = 300;
height = 190;
mwindow = mGUI->createWidget<MyGUI::Window>
("MW_Window",
mWidth-width-120, mHeight-height-160, // Position
width, height, // Size
MyGUI::ALIGN_DEFAULT, "Overlapped");
mwindow->setCaption("Skin test");
mwindow->setMinMax(100, 140, 1000, 1000);
mwindow->setAlpha(1);
// 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->setColour(Ogre::ColourValue::White);
tmp->setFontName("ManualFont");
tmp->setCaption("ABC");
//*/
}
extern "C" void gui_setFpsText(char *str)
{
if(FPSText != NULL)
FPSText->setCaption(str);
}

@ -28,12 +28,13 @@
#include <OgreConfigFile.h>
#include <OgreStringConverter.h>
#include <OgreException.h>
#include <OgreOverlayElementFactory.h>
#include <OgreArchive.h>
#include <OgreArchiveFactory.h>
#include <OIS/OIS.h>
#include <MyGUI.h>
using namespace Ogre;
RenderWindow* mWindow;
@ -54,13 +55,17 @@ OIS::InputManager *mInputManager;
OIS::Mouse *mMouse;
OIS::Keyboard *mKeyboard;
// The global GUI object
MyGUI::Gui *mGUI;
int guiMode = 0;
// Root node for all objects added to the scene. This is rotated so
// that the OGRE coordinate system matches that used internally in
// Morrowind.
SceneNode *root;
// Include the other parts of the code, and make one big object file.
#include "cpp_mygui.cpp"
#include "cpp_framelistener.cpp"
#include "cpp_bsaarchive.cpp"
#include "cpp_interface.cpp"
#include "cpp_overlay.cpp"

@ -1,74 +0,0 @@
/*
OpenMW - The completely unofficial reimplementation of Morrowind
Copyright (C) 2008 Nicolay Korslund
Email: < korslund@gmail.com >
WWW: http://openmw.snaptoad.com/
This file (cpp_overlay.cpp) is part of the OpenMW package.
OpenMW is distributed as free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License
version 3, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
version 3 along with this program. If not, see
http://www.gnu.org/licenses/ .
*/
OverlayManager *om;
Overlay *owl;
PanelOverlayElement *cont;
int visible;
extern "C" void ogre_debug(int32_t i)
{
std::cerr << "Running ogre_debug(" << i << ")\n";
if(om)
{
if(visible)
{
visible = 0;
owl->hide();
}
else
{
visible = 1;
owl->show();
}
return;
}
om = OverlayManager::getSingletonPtr();
owl = om->create("HUD");
OverlayElement *e = om->createOverlayElementFromFactory("Panel", "Hopp");
cont = (PanelOverlayElement*)e;
cont->setDimensions(0.3, 0.5);
cont->setPosition(0.1, 0.2);
cont->setMaterialName(LASTNAME);
/*
* I suggest creating a custom material based on a "live" texture,
* where we can specify alpha transparency and draw everything
* ourselves. (Reinvent the wheel at every chance! :)
*/
MaterialPtr material = MaterialManager::getSingleton().getByName(LASTNAME);
std::cerr << "Material " << LASTNAME << "\n";
Pass* pass = material->getTechnique(0)->getPass(0);
pass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
owl->add2D(cont);
owl->show();
visible = 1;
}
Loading…
Cancel
Save