mirror of https://github.com/OpenMW/openmw.git
More work on the GUI. Tried (and failed) to make the fonts work.
git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@85 ea6a568a-9f4f-0410-981a-c910a81bb256pull/7/head
parent
17a2c67d26
commit
fdf9da706f
@ -1,146 +0,0 @@
|
||||
|
||||
/*
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 103 B After Width: | Height: | Size: 103 B |
@ -1,7 +1,7 @@
|
||||
<?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">
|
||||
<Font name="MyGUI_CoreFont.18" source="Comic.TTF" size="18" resolution="72" antialias_colour="false" space_width="4" tab_count="4" spacer="5">
|
||||
<Code range="33 126"/>
|
||||
<Code range="1025 1105"/>
|
||||
<Code range="8470 8470" help="№"/>
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
@ -0,0 +1,43 @@
|
||||
<?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"/>
|
||||
<Code range="8470 8470" help="№"/>
|
||||
<Code hide="128"/>
|
||||
<Code hide="1026 1039"/>
|
||||
<Code hide="1104"/>
|
||||
</Font>
|
||||
|
||||
<Font name="daedric" source="daedric.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>
|
||||
|
||||
<Font name="dorcla" source="dorcla.ttf" size="20" resolution="72" antialias_colour="false" space_width="5" 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>
|
||||
|
||||
<Font name="perrygot" source="perrygot.ttf" size="16" resolution="72" antialias_colour="false" space_width="4" 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,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Pointer">
|
||||
|
||||
<Pointer layer="Pointer" texture="mwpointer.png" default="arrow">
|
||||
<Info name="arrow" point="7 0" size="32 32" offset="0 0 32 32"/>
|
||||
<Info name="hresize" point="16 14" size="32 32" offset="32 0 32 32"/>
|
||||
<Info name="vresize" point="17 16" size="32 32" offset="0 32 32 32"/>
|
||||
<Info name="dresize" point="17 15" size="32 32" offset="32 32 32 32"/>
|
||||
<Info name="dresize2" point="15 15" size="32 32" offset="64 32 32 32"/>
|
||||
</Pointer>
|
||||
|
||||
</MyGUI>
|
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Skin">
|
||||
<!-- Button graphics -->
|
||||
<Skin name="BTN_Top" size="128 4" texture="menu_button_frame_top.dds">
|
||||
<BasisSkin type="MainSkin" offset = "0 0 128 4">
|
||||
<State name="normal" offset = "0 0 128 4"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
<Skin name="BTN_Bottom" size="128 4" texture="menu_button_frame_bottom.dds">
|
||||
<BasisSkin type="MainSkin" offset = "0 0 128 4">
|
||||
<State name="normal" offset = "0 0 128 4"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
<Skin name="BTN_Left" size="4 16" texture="menu_button_frame_left.dds">
|
||||
<BasisSkin type="MainSkin" offset = "0 0 4 16">
|
||||
<State name="normal" offset = "0 0 4 16"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
<Skin name="BTN_Right" size="4 16" texture="menu_button_frame_right.dds">
|
||||
<BasisSkin type="MainSkin" offset = "0 0 4 16">
|
||||
<State name="normal" offset = "0 0 4 16"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
<Skin name="BTN_TopLeft" size="4 4" texture="menu_button_frame_top_left_corner.dds">
|
||||
<BasisSkin type="MainSkin" offset = "0 0 4 4">
|
||||
<State name="normal" offset = "0 0 4 4"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
<Skin name="BTN_TopRight" size="4 4" texture="menu_button_frame_top_right_corner.dds">
|
||||
<BasisSkin type="MainSkin" offset = "0 0 4 4">
|
||||
<State name="normal" offset = "0 0 4 4"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
<Skin name="BTN_BottomLeft" size="4 4" texture="menu_button_frame_bottom_left_corner.dds">
|
||||
<BasisSkin type="MainSkin" offset = "0 0 4 4">
|
||||
<State name="normal" offset = "0 0 4 4"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
<Skin name="BTN_BottomRight" size="4 4" texture="menu_button_frame_bottom_right_corner.dds">
|
||||
<BasisSkin type="MainSkin" offset = "0 0 4 4">
|
||||
<State name="normal" offset = "0 0 4 4"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
|
||||
<!-- Button widget -->
|
||||
<Skin name="MW_Button" size="136 24">
|
||||
<Property key="FontName" value = "MyGUI_CoreFont.18" />
|
||||
<!--Property key="FontName" value = "cards" /-->
|
||||
<Property key="FontHeight" value = "18" />
|
||||
<Property key="AlignText" value = "ALIGN_CENTER" />
|
||||
<Property key="Colour" value = "0.6 0.6 0.6" />
|
||||
|
||||
<Child type="Widget" skin="BTN_Left" offset="0 4 4 16" align="ALIGN_VSTRETCH ALIGN_LEFT"/>
|
||||
<Child type="Widget" skin="BTN_Right" offset="132 4 4 16" align="ALIGN_VSTRETCH ALIGN_RIGHT"/>
|
||||
<Child type="Widget" skin="BTN_Top" offset="4 0 128 4" align="ALIGN_HSTRETCH ALIGN_TOP"/>
|
||||
<Child type="Widget" skin="BTN_Bottom" offset="4 20 128 4" align="ALIGN_HSTRETCH ALIGN_BOTTOM"/>
|
||||
<Child type="Widget" skin="BTN_TopLeft" offset="0 0 4 4" align="ALIGN_TOP ALIGN_LEFT"/>
|
||||
<Child type="Widget" skin="BTN_TopRight" offset="132 0 4 4" align="ALIGN_TOP ALIGN_RIGHT"/>
|
||||
<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">
|
||||
<!--State name="disable" colour="0.87 0.87 0.87"/-->
|
||||
<!--State name="normal" colour="0 0 0"/-->
|
||||
<State name="active" colour="FF0000"/>
|
||||
<State name="pressed" colour="0000FF"/>
|
||||
<State name="select" colour="00FF00"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
</MyGUI>
|
Loading…
Reference in New Issue