010 Sweetscape Template for ui.dat EP38

Junior Spellweaver
Joined
Feb 24, 2024
Messages
141
Reaction score
423
Here you go... Enjoy it :)

Special Thanks to Michael.

C-like:
//--------------------------------------##
// Game: CABAL Online
// File: ui.dat
// Description: Template for CABAL's ui.dat file
//--------------------------------------##
// Authors Michael K
// Website: https://epidal.github.io/
// Modified by notestsoft
//--------------------------------------##

typedef struct {
    ushort length;
    if (length != 0)
        char text[length];
} Text <read=TextRead, write=TextWrite>;

typedef enum <int> {
    Hidden = 0,
    Visible = 1,
} state;

typedef enum <int> {
    TopLeft = 0,
    TopCenter = 1,
    TopRight = 2,
    CenterLeft = 4,
    CenterCenter = 5,
    CenterRight = 6,
    BottomLeft = 8,
    BottomCenter = 9,
    BottomRight = 10
} dock;

typedef struct {
    int x;
    int y;
} point;


typedef struct {
    ubyte blue, green, red, alpha;
} BGRA <read=BGRARead, write=BGRAWrite>;

//-Structures---------------------------

typedef struct {
    point TopLeft;
    point BottomRight;
} rect;

typedef struct {
    int32 X;
    int32 Y;
    int32 Width;
    int32 Height;
} Rectangle;

typedef struct {
    ushort FileNameLength;
    char FileName[FileNameLength];
    int32 Width;
    int32 Height;
} TextureFile;

typedef struct {
    int EventID;
    Text Target1;
    Text Target2;
} Event;

typedef struct {
    int TextureID;
    int X;
    int Y;
    int Width;
    int Height;
} UITexture;

typedef struct {
    ushort NameLength;
    char Name[NameLength];
    int32 ID;
    int32 X;
    int32 Y;
    int32 Width;
    int32 Height;
    int32 Bold;
    BGRA ColourNormal;
    BGRA ColourHover;
    BGRA ColourPressed;
    dock Alignment;
    int TextIndex;
} UIText;

typedef struct {
    Text ID;
    Text ParentID;
    Text name3;
    int32 unk0;
    int32 ID;  // maybe?
    int32 ParentID;
    int32 Type;   // 0 = Container, 1 = Button, 2 = TextField, 3 = Grid, 4 = UIText, 5 = ProgressBar, 6 = UITexture, 7 = Checkbox, 8 = Slider, 9 = tre?, 10 = tri?, 11 = scr?, 12 = Tab, 13 = mtl?, 14 = cob_tab?, 15 = ?, 16 = Gauge
    Rectangle Rect;
    int32 Render;
    int32 Init;
    int32 Extra1;
    int32 Extra2;
    int32 Focus;
    int32 EventIndex;
    int32 EventCount;
    int32 ImageIndex;
    int32 ImageCount;
    int32 TextIndex;
    int32 TextCount;
    dock Alignment;
} UIElement;

typedef struct {
    unsigned byte r, g, b, a;
} RGBA;

typedef struct {
    RGBA r <hidden=true>;
    ParseRGBA(r);
    RGBA colour;
} TextColor;


//-Main---------------------------------

FSeek(0);

struct {
    short Version;
    if (Version < 5) {
        short Unknown1;
        short Unknown2;
        short Unknown3;
    } else {
        short Unknown1;
        int Unknown2;
        int Unknown3;
    }
} Header;

struct {
    int32 TextureFileCount;
    TextureFile TextureFiles[TextureFileCount] <optimize=false>;
} TextureFileList;

struct {
    int32 ColorCount;
    TextColor Colors[ColorCount] <optimize=false>;
} ColorList;

struct {
    int32 UITextureCount;
    UITexture UITextures[UITextureCount] <optimize=false>;
} TextureList;

struct {
    int32 EventCount;
    Event Events[EventCount] <optimize=false>;
} EventList;

struct {
    int32 UITextCount;
    UIText UITexts[UITextCount] <optimize=false>;
} TextList;

struct {
    int32 UIElementCount;
    UIElement UIElements[UIElementCount] <optimize=false>;
} ElementList;


//-Functions----------------------------

void ParseRGBA(RGBA &r) {
    FSeek(FTell() - 4);
    local int blue = (r.b);
    local int green = (r.g);
    local int red = (r.r);
    local int bc = (int)blue * 0x10000 + (int)green * 0x100 + (int)red;
    SetBackColor(bc);
}
 
Back