Bitmap window generator function

Post here your demos and examples with the source files.
Forum rules
Always post the games with a screenshot.
The file must have the ged and data files (complete game source)
Use the forum attachment to post the files.
It is always better to use the first post to put the game files

Bitmap window generator function

Postby Game A Gogo » Thu Jun 24, 2010 6:20 pm

I created today a function that allows you to import a single bitmap image and use the different parts inside the bitmap to reproduce a themed window of any size, with transparent!

how it works:
First of all, the function "ImpBmp("image.bmp")" will load up a bitmap in memory (If header information meets specification)
Code: Select all
void ImpBmp(char*FPath)
{
    int BmpHeader[64],i,j;
    FILE*BMPF=fopen(FPath, "r+b");
    for(i=0; i<64; i++)
    {
        BmpHeader[i]=fgetc(BMPF);
    }
    if(BmpHeader[0]==66 && BmpHeader[1]==77)//Checks if this really is a bmp!
    {
        if(BmpHeader[18]==128 && BmpHeader[22]==128)//Checks if the size is good
        {
            if(BmpHeader[28]==24)//Checks if it's the correct BPP
            {
                fseek(BMPF, BmpHeader[10], SEEK_SET);
                for(i=127; i>=0; i--)
                {
                    for(j=0; j<128; j++)
                    {
                        Wimg_Blue[j][i]=fgetc(BMPF);
                        Wimg_Green[j][i]=fgetc(BMPF);
                        Wimg_Red[j][i]=fgetc(BMPF);
                    }
                }
            }
        }
    }
    fclose(BMPF);
}

with the bitmap loaded and organised to be more "human readable", you can draw the window with the function "DW_Main(0,0,1,320,240)", which will draw 9 different window component and strech the ones needed to be.
Code: Select all
void DW_TLC(int W_Xo, int W_Yo, int W_Act) //Top Left Corner
{
    int i,j;
    for(i=0; i<8; i++)
    {
        for(j=0; j<16; j++)
        {
            if(Wimg_Red[0][0]==Wimg_Red[i][j+1+(17*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[i][j+1+(17*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[i][j+1+(17*(1-W_Act))])
            {
                setpen(0,0,0,1,1);
            }
            else setpen(Wimg_Red[i][j+1+(17*(1-W_Act))],Wimg_Green[i][j+1+(17*(1-W_Act))],Wimg_Blue[i][j+1+(17*(1-W_Act))],0,1);
            putpixel(i+W_Xo,j+W_Yo);
        }
    }
}
void DW_TTB(int W_Xo, int W_Yo, int W_Act, float W_WWidth) //Top Title Bar
{
    int i,j,pi;
    for(i=0; i<W_WWidth; i++)
    {
        for(j=0; j<16; j++)
        {
            pi=min(63,round((i/W_WWidth)*64));
            if(Wimg_Red[0][0]==Wimg_Red[pi+9][j+1+(17*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[pi+9][j+1+(17*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[pi+9][j+1+(17*(1-W_Act))])
            {
                setpen(0,0,0,1,1);
            }
            else setpen(Wimg_Red[pi+9][j+1+(17*(1-W_Act))],Wimg_Green[pi+9][j+1+(17*(1-W_Act))],Wimg_Blue[pi+9][j+1+(17*(1-W_Act))],0,1);
            putpixel(i+W_Xo+8,j+W_Yo);
        }
    }
 
}
void DW_TRC(int W_Xo, int W_Yo, int W_Act, int W_WWidth) //Top Right Corner
{
    int i,j;
    for(i=0; i<8; i++)
    {
        for(j=0; j<16; j++)
        {
            if(Wimg_Red[0][0]==Wimg_Red[i+74][j+1+(17*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[i+74][j+1+(17*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[i+74][j+1+(17*(1-W_Act))])
            {
                setpen(0,0,0,1,1);
            }
            else setpen(Wimg_Red[i+74][j+1+(17*(1-W_Act))],Wimg_Green[i+74][j+1+(17*(1-W_Act))],Wimg_Blue[i+74][j+1+(17*(1-W_Act))],0,1);
            putpixel(i+W_Xo+W_WWidth+8,j+W_Yo);
        }
    }
}
void DW_LSB(int W_Xo, int W_Yo, int W_Act, float W_WHeight) //Left Side Border
{
    int i,j,pj;
    for(i=0; i<6; i++)
    {
        for(j=0; j<W_WHeight; j++)
        {
            pj=min(63,round((j/W_WHeight)*64));
            if(Wimg_Red[0][0]==Wimg_Red[i+(14*(1-W_Act))][pj+35]&&Wimg_Green[0][0]==Wimg_Green[i+(14*(1-W_Act))][pj+35]&&Wimg_Blue[0][0]==Wimg_Blue[i+(14*(1-W_Act))][pj+35])
            {
                setpen(0,0,0,1,1);
            }
            else setpen(Wimg_Red[i+(14*(1-W_Act))][pj+35],Wimg_Green[i+(14*(1-W_Act))][pj+35],Wimg_Blue[i+(14*(1-W_Act))][pj+35],0,1);
            putpixel(i+W_Xo,j+W_Yo+16);
        }
    }
}
void DW_RSB(int W_Xo, int W_Yo, int W_Act, int W_WWidth, float W_WHeight) //Right Side Border
{
    int i,j,pj;
    for(i=0; i<6; i++)
    {
        for(j=0; j<W_WHeight; j++)
        {
            pj=min(63,round((j/W_WHeight)*64));
            if(Wimg_Red[0][0]==Wimg_Red[7+i+(14*(1-W_Act))][pj+35]&&Wimg_Green[0][0]==Wimg_Green[7+i+(14*(1-W_Act))][pj+35]&&Wimg_Blue[0][0]==Wimg_Blue[7+i+(14*(1-W_Act))][pj+35])
            {
                setpen(0,0,0,1,1);
            }
            else setpen(Wimg_Red[7+i+(14*(1-W_Act))][pj+35],Wimg_Green[7+i+(14*(1-W_Act))][pj+35],Wimg_Blue[7+i+(14*(1-W_Act))][pj+35],0,1);
            putpixel(10+i+W_Xo+W_WWidth,j+W_Yo+16);
        }
    }
}
void DW_BLC(int W_Xo, int W_Yo, int W_Act, int W_WHeight) //Bottom Left Corner
{
    int i,j;
    for(i=0; i<8; i++)
    {
        for(j=0; j<8; j++)
        {
            if(Wimg_Red[0][0]==Wimg_Red[i+28][j+35+(9*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[i+28][j+35+(9*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[i+28][j+35+(9*(1-W_Act))])
            {
                setpen(0,0,0,1,1);
            }
            else setpen(Wimg_Red[i+28][j+35+(9*(1-W_Act))],Wimg_Green[i+28][j+35+(9*(1-W_Act))],Wimg_Blue[i+28][j+35+(9*(1-W_Act))],0,1);
            putpixel(i+W_Xo,j+W_Yo+W_WHeight+16);
        }
    }
}
void DW_BRC(int W_Xo, int W_Yo, int W_Act, int W_WWidth, int W_WHeight) //Bottom Right Corner
{
    int i,j;
    for(i=0; i<8; i++)
    {
        for(j=0; j<8; j++)
        {
            if(Wimg_Red[0][0]==Wimg_Red[i+37][j+35+(9*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[i+37][j+35+(9*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[i+37][j+35+(9*(1-W_Act))])
            {
                setpen(0,0,0,1,1);
            }
            else setpen(Wimg_Red[i+37][j+35+(9*(1-W_Act))],Wimg_Green[i+37][j+35+(9*(1-W_Act))],Wimg_Blue[i+37][j+35+(9*(1-W_Act))],0,1);
            putpixel(i+W_Xo+W_WWidth+8,j+W_Yo+W_WHeight+16);
        }
    }
}
void DW_BBL(int W_Xo, int W_Yo, int W_Act, float W_WWidth, int W_WHeight) //Bottom Border Line
{
    int i,j,pi;
    for(i=0; i<W_WWidth; i++)
    {
        for(j=0; j<6; j++)
        {
            pi=min(63,round((i/W_WWidth)*64));
            if(Wimg_Red[0][0]==Wimg_Red[pi][j+100+(7*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[pi][j+100+(7*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[pi][j+100+(7*(1-W_Act))])
            {
                setpen(0,0,0,1,1);
            }
            else setpen(Wimg_Red[pi][j+100+(7*(1-W_Act))],Wimg_Green[pi][j+100+(7*(1-W_Act))],Wimg_Blue[pi][j+100+(7*(1-W_Act))],0,1);
            putpixel(i+W_Xo+8,j+W_Yo+W_WHeight+18);
        }
    }
}
void DW_WA(int W_Xo, int W_Yo, float W_WWidth, float W_WHeight) //Working Area
{
    int i,j,pi,pj;
    if(W_WWidth>0&&W_WHeight>0)
    {
        for(i=0; i<W_WWidth+4; i++)
        {
            for(j=0; j<W_WHeight+2; j++)
            {
                pi=min(63,round((i/W_WWidth)*64));
                pj=min(63,round((j/W_WHeight)*64));
                setpen(Wimg_Red[pi+46][pj+35],Wimg_Green[pi+46][pj+35],Wimg_Blue[pi+46][pj+35],0,1);
                putpixel(i+W_Xo+6,j+W_Yo+16);
            }
        }
    }
}
void DW_Main(int W_Xo, int W_Yo, int W_Act, int W_WWidth, int W_WHeight)
{
 
    DW_TLC(W_Xo,W_Yo,W_Act);
    DW_TTB(W_Xo,W_Yo,W_Act,W_WWidth);
    DW_TRC(W_Xo,W_Yo,W_Act,W_WWidth);
    DW_LSB(W_Xo,W_Yo,W_Act,W_WHeight);
    DW_RSB(W_Xo,W_Yo,W_Act,W_WWidth,W_WHeight);
    DW_BLC(W_Xo,W_Yo,W_Act,W_WHeight);
    DW_BRC(W_Xo,W_Yo,W_Act,W_WWidth,W_WHeight);
    DW_BBL(W_Xo,W_Yo,W_Act,W_WWidth,W_WHeight);
    DW_WA(W_Xo,W_Yo,W_WWidth,W_WHeight);
 
}


NOTE: You cannot call DW_Main() before ImpBmp(), well you can, except it'll give out a window completly transparent

how to use:

very simple, put the two top scripts in the GLOBAL SCRIPT
On the view actor -> create actor, do a script:
Code: Select all
ImpBmp("Default.bmp");//Wait! Make sure you replaced "Default.bmp" with the name of your bitmap!

On a canvas actor when you need to draw a window, call the function "DW_Main(0,0,1,100,100)" in a script, the syntax of the function is as follow: DW_Main(Position Offset on the X axis, Position Offset on the Y axis, 0=Window is inactive; 1=Window is active(Selected), Width of "working" region in window, Height of "working" region in window);

how to create a skin:
data.PNG
Sample Window Skin
data.PNG (1.49 KiB) Viewed 53644 times

Elements in gray are never streched
Elements in yellow are streched along the X axis only
Elements in blue are streched along the Y axis only
Element in green is streched on both axis
Darker elements are inactive
1:Active Top Left Corner, size:8x16 offset:0,1
2:Active Title Bar, Resizable, size:64x16 offset:9,1
3:Active Top Right Corner, size:8x16 offset:74,1
4:Inactive Top Left Corner, size:8x16 offset:0,18
5:Inactive Title Bar, Resizable, size:64x16 offset:9,18
6:Inactive Top Right Corner, size:8x16 offset:74,18
7:Active Left Border, Resizable, size:6x64 offset:0,35
8:Active Right Border, Resizable, size:6x64 offset:7,35
9:Inactive Left Border, Resizable, size:6x64 offset:14,35
A:Inactive Right Border, Resizable, size:6x64 offset:21,35
B:Active Bottom Left Corner, size:8x8 offset:28,35 *
C:Active Bottom Right Corner, size:8x8 offset:37,35 **
D:Inactive Bottom Left Corner, size:8x8 offset:28,44 *
E:Inactive Bottom Right Corner, size:8x8 offset:37,44 **
F:Working Area, Resizable, size:64x64 offset:46,35
10:Active Bottom Border, Resizable, size:64x6 offset:0,100
11:Inactive Bottom Border, Resizable, size:64x6 offset:0,100
*A square of 2x2 pixels gets overlayed by the Working Area on the top right corner of the element
**A square of 2x2 pixels gets overlayed by the Working Area on the top left corner of the element
NOTE: The transparent color is given by the first pixel found (0,0); any pixels matching that one will be considered as a transparent color. Due to this, all elements are placed a pixel lower so it's possible to have no transparency

Enjoy this neat function, and I hope you will like it! no credits needed, but appreciated :)
Attachments
window.zip
The zip file containing the GED file and some samples of window skins, use the keys: 1,2,3 and 4 to switch between them!
(230.56 KiB) Downloaded 526 times
sample.JPG
A preview of the window when drawn, active and inactive
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Bitmap window generator function

Postby Hblade » Thu Jun 24, 2010 6:51 pm

BRAVO :D!
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Bitmap window generator function

Postby Game A Gogo » Thu Jun 24, 2010 6:54 pm

I wonder if people will be smart enough and will do effects with the windows :) I know I will when I will be using this
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Bitmap window generator function

Postby Camper1995 » Thu Jun 24, 2010 8:50 pm

Awesome work! :)

By the way, welcome back Game a Gogo! :)

Its little bit bad, that the demo is slowly. :-p
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Bitmap window generator function

Postby Game A Gogo » Thu Jun 24, 2010 9:19 pm

indeed, except it wouldn't be in real time, because having it in draw actor is extremely useless, here was just to show the resizing ability!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Bitmap window generator function

Postby lcl » Sat Apr 30, 2011 1:58 pm

This is simply awesome man!
Very good job! :D

I have to try to study this for making some
things to lclOS. :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Bitmap window generator function

Postby again » Sat Apr 30, 2011 3:38 pm

Game a gogo coding skills are beyond incredible , is he human? Excellent job!!!
Free windows mobile games like doodle jump and super mario bros
http://krenisis.freeforums.org/
again
 
Posts: 258
Joined: Wed Jan 19, 2011 7:06 pm
Score: 33 Give a positive score

Re: Bitmap window generator function

Postby Game A Gogo » Sat Apr 30, 2011 4:10 pm

Thanks a lot!

I also have one with button integration. Like for the X button and normal buttons. Want me to post it?
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Bitmap window generator function

Postby lcl » Sat Apr 30, 2011 5:42 pm

Sure. :) that would be awesome! :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Bitmap window generator function

Postby Game A Gogo » Sat Apr 30, 2011 10:02 pm

Code: Select all
int W_ActW=0;
void DW_TLC(int W_Xo, int W_Yo, int W_Act) //Top Left Corner
{
    int i=0,j=0;
    for(i=0; i<8; i++)
    {
        for(j=0; j<16; j++)
        {
            if(Wimg_Red[0][0]==Wimg_Red[i][j+1+(16*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[i][j+1+(16*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[i][j+1+(16*(1-W_Act))])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[i][j+1+(16*(1-W_Act))],Wimg_Green[i][j+1+(16*(1-W_Act))],Wimg_Blue[i][j+1+(16*(1-W_Act))],0,1);
                putpixel(i+W_Xo,j+W_Yo);
            }
        }
    }
}
void DW_TTB(int W_Xo, int W_Yo, int W_Act, float W_WWidth) //Top Title Bar
{
    int i=0,j=0,pi=0;
    for(i=0; i<W_WWidth; i++)
    {
        for(j=0; j<16; j++)
        {
            pi=min(63,round((i/W_WWidth)*64));
            if(Wimg_Red[0][0]==Wimg_Red[pi+8][j+1+(16*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[pi+8][j+1+(16*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[pi+8][j+1+(16*(1-W_Act))])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[pi+8][j+1+(16*(1-W_Act))],Wimg_Green[pi+8][j+1+(16*(1-W_Act))],Wimg_Blue[pi+8][j+1+(16*(1-W_Act))],0,1);
                putpixel(i+W_Xo+8,j+W_Yo);
            }
        }
    }
 
}
void DW_TRC(int W_Xo, int W_Yo, int W_Act, int W_WWidth) //Top Right Corner
{
    int i=0,j=0;
    for(i=0; i<8; i++)
    {
        for(j=0; j<16; j++)
        {
            if(Wimg_Red[0][0]==Wimg_Red[i+72][j+1+(16*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[i+72][j+1+(16*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[i+72][j+1+(16*(1-W_Act))])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[i+72][j+1+(16*(1-W_Act))],Wimg_Green[i+72][j+1+(16*(1-W_Act))],Wimg_Blue[i+72][j+1+(16*(1-W_Act))],0,1);
                putpixel(i+W_Xo+W_WWidth+8,j+W_Yo);
            }
        }
    }
}
void DW_LSB(int W_Xo, int W_Yo, int W_Act, float W_WHeight) //Left Side Border
{
    int i=0,j=0,pj=0;
    for(i=0; i<6; i++)
    {
        for(j=0; j<W_WHeight; j++)
        {
            pj=min(63,round((j/W_WHeight)*64));
            if(Wimg_Red[0][0]==Wimg_Red[i+(12*(1-W_Act))][pj+33]&&Wimg_Green[0][0]==Wimg_Green[i+(12*(1-W_Act))][pj+33]&&Wimg_Blue[0][0]==Wimg_Blue[i+(12*(1-W_Act))][pj+33])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[i+(12*(1-W_Act))][pj+33],Wimg_Green[i+(12*(1-W_Act))][pj+33],Wimg_Blue[i+(12*(1-W_Act))][pj+33],0,1);
                putpixel(i+W_Xo,j+W_Yo+16);
            }
        }
    }
}
void DW_RSB(int W_Xo, int W_Yo, int W_Act, int W_WWidth, float W_WHeight) //Right Side Border
{
    int i=0,j=0,pj=0;
    for(i=0; i<6; i++)
    {
        for(j=0; j<W_WHeight; j++)
        {
            pj=min(63,round((j/W_WHeight)*64));
            if(Wimg_Red[0][0]==Wimg_Red[6+i+(12*(1-W_Act))][pj+36]&&Wimg_Green[0][0]==Wimg_Green[6+i+(12*(1-W_Act))][pj+33]&&Wimg_Blue[0][0]==Wimg_Blue[6+i+(12*(1-W_Act))][pj+33])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[6+i+(12*(1-W_Act))][pj+33],Wimg_Green[6+i+(12*(1-W_Act))][pj+33],Wimg_Blue[6+i+(12*(1-W_Act))][pj+33],0,1);
                putpixel(10+i+W_Xo+W_WWidth,j+W_Yo+16);
            }
        }
    }
}
void DW_BLC(int W_Xo, int W_Yo, int W_Act, int W_WHeight) //Bottom Left Corner
{
    int i=0,j=0;
    for(i=0; i<8; i++)
    {
        for(j=0; j<8; j++)
        {
            if(Wimg_Red[0][0]==Wimg_Red[i+96][j+(8*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[i+96][j+(8*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[i+96][j+(8*(1-W_Act))])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[i+96][j+(8*(1-W_Act))],Wimg_Green[i+96][j+(8*(1-W_Act))],Wimg_Blue[i+96][j+(8*(1-W_Act))],0,1);
                putpixel(i+W_Xo,j+W_Yo+W_WHeight+16);
            }
        }
    }
}
void DW_BRC(int W_Xo, int W_Yo, int W_Act, int W_WWidth, int W_WHeight, int W_Type) //Bottom Right Corner
{
    int i,j;
    for(i=0; i<8; i++)
    {
        for(j=0; j<8; j++)
        {
            if(Wimg_Red[0][0]==Wimg_Red[i+104+(8*W_Type)][j+(8*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[i+104][j+(8*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[i+104+(8*W_Type)][j+(8*(1-W_Act))])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[i+104+(8*W_Type)][j+(8*(1-W_Act))],Wimg_Green[i+104+(8*W_Type)][j+(8*(1-W_Act))],Wimg_Blue[i+104+(8*W_Type)][j+(8*(1-W_Act))],0,1);
                putpixel(i+W_Xo+W_WWidth+8,j+W_Yo+W_WHeight+16);
            }
        }
    }
}
void DW_BBL(int W_Xo, int W_Yo, int W_Act, float W_WWidth, int W_WHeight) //Bottom Border Line
{
    int i=0,j=0,pi=0;
    for(i=0; i<W_WWidth; i++)
    {
        for(j=0; j<6; j++)
        {
            pi=min(63,round((i/W_WWidth)*64));
            if(Wimg_Red[0][0]==Wimg_Red[pi][j+97+(6*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[pi][j+97+(6*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[pi][j+97+(6*(1-W_Act))])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[pi][j+97+(6*(1-W_Act))],Wimg_Green[pi][j+97+(6*(1-W_Act))],Wimg_Blue[pi][j+97+(6*(1-W_Act))],0,1);
                putpixel(i+W_Xo+8,j+W_Yo+W_WHeight+18);
            }
        }
    }
}
void DW_WA(int W_Xo, int W_Yo, float W_WWidth, float W_WHeight, int W_DWA) //Working Area
{
    int i=0,j=0,pi=0,pj=0;
    if(W_DWA)
    {
    if(W_WWidth>0&&W_WHeight>0)
    {
        for(i=0; i<W_WWidth+4; i++)
        {
            for(j=0; j<W_WHeight+2; j++)
            {
                pi=min(63,round((i/W_WWidth)*64));
                pj=min(63,round((j/W_WHeight)*64));
                setpen(Wimg_Red[pi+24][pj+33],Wimg_Green[pi+24][pj+33],Wimg_Blue[pi+24][pj+33],0,1);
                putpixel(i+W_Xo+6,j+W_Yo+16);
            }
        }
    }
    }
}
void DW_SetTitle(int W_Xo, int W_Yo, int W_Act, char*W_Title)
{
    if(W_Title)
    {
        strcpy(text, W_Title);
        x=(-parent.width/2)+10;
        y=(-parent.height/2)+2;
    }
}
void DW_SetMessage(int W_Xo, int W_Yo, int W_Xr, int W_Yr)
{
    x=(-parent.width/2)+10+(W_Xr*8);
    y=(-parent.height/2)+22+(W_Yr*16);
}
void DW_DrawClose(int W_Xo, int W_Yo, int W_WWidth, int W_BState)
{
    int i=0,j=0;
    x=(-parent.width/2)+W_WWidth;
    y=(-parent.height/2);
    for(i=0; i<16; i++)
    {
        for(j=0; j<16; j++)
        {
            if(Wimg_Red[0][0]==Wimg_Red[i+80][j+1+(16*W_BState)]&&Wimg_Green[0][0]==Wimg_Green[i+80][j+1+(16*W_BState)]&&Wimg_Blue[0][0]==Wimg_Blue[i+80][j+1+(16*W_BState)])
            {
                setpen(0,0,0,1,1);
            }
            else setpen(Wimg_Red[i+80][j+1+(16*W_BState)],Wimg_Green[i+80][j+1+(16*W_BState)],Wimg_Blue[i+80][j+1+(16*W_BState)],0,1);
            putpixel(i+W_Xo,j+W_Yo);
        }
    }
}
void DW_Main(int Xo, int Yo, int Act, int WWidth, int WHeight, int Type, int DWA)
{
 
    DW_TLC(Xo,Yo,Act);
    DW_TTB(Xo,Yo,Act,WWidth);
    DW_TRC(Xo,Yo,Act,WWidth);
    DW_LSB(Xo,Yo,Act,WHeight);
    DW_RSB(Xo,Yo,Act,WWidth,WHeight);
    DW_BLC(Xo,Yo,Act,WHeight);
    DW_BRC(Xo,Yo,Act,WWidth,WHeight,Type);
    DW_BBL(Xo,Yo,Act,WWidth,WHeight);
    DW_WA(Xo,Yo,WWidth,WHeight,DWA);
 
}
void DB_BTL(int W_Xo, int W_Yo, int W_BState) //Button Top Left (Corner)
{
    int i=0,j=0;
    for(i=0; i<8; i++)
    {
        for(j=0; j<8; j++)
        {
            if(Wimg_Red[0][0]==Wimg_Red[i+96][j+32+(32*W_BState)]&&Wimg_Green[0][0]==Wimg_Green[i+96][j+32+(32*W_BState)]&&Wimg_Blue[0][0]==Wimg_Blue[i+96][j+32+(32*W_BState)])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[i+96][j+32+(32*W_BState)],Wimg_Green[i+96][j+32+(32*W_BState)],Wimg_Blue[i+96][j+32+(32*W_BState)],0,1);
                putpixel(i+W_Xo,j+W_Yo);
            }
        }
    }
}
void DB_BTB(int W_Xo, int W_Yo, int W_BState, float W_BWidth) //Button Top Border
{
    int i=0,j=0,pi=0;
    for(i=0; i<W_BWidth; i++)
    {
        for(j=0; j<8; j++)
        {
            pi=min(15,round((i/W_BWidth)*16));
            if(Wimg_Red[0][0]==Wimg_Red[pi+104][j+32+(32*W_BState)]&&Wimg_Green[0][0]==Wimg_Green[pi+104][j+32+(32*W_BState)]&&Wimg_Blue[0][0]==Wimg_Blue[pi+104][j+32+(32*W_BState)])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[pi+104][j+32+(32*W_BState)],Wimg_Green[pi+104][j+32+(32*W_BState)],Wimg_Blue[pi+104][j+32+(32*W_BState)],0,1);
                putpixel(i+W_Xo+8,j+W_Yo);
            }
        }
    }
}
void DB_BTR(int W_Xo, int W_Yo, int W_BState, int W_BWidth) //Button Top Right (Corner)
{
    int i=0,j=0;
    for(i=0; i<8; i++)
    {
        for(j=0; j<8; j++)
        {
            if(Wimg_Red[0][0]==Wimg_Red[i+120][j+32+(32*W_BState)]&&Wimg_Green[0][0]==Wimg_Green[i+120][j+32+(32*W_BState)]&&Wimg_Blue[0][0]==Wimg_Blue[i+120][j+32+(32*W_BState)])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[i+120][j+32+(32*W_BState)],Wimg_Green[i+120][j+32+(32*W_BState)],Wimg_Blue[i+120][j+32+(32*W_BState)],0,1);
                putpixel(i+W_Xo+W_BWidth+8,j+W_Yo);
            }
        }
    }
}
void DB_BLB(int W_Xo, int W_Yo, int W_BState, float W_BHeight) //Button Left Border
{
    int i=0,j=0,pj=0;
    for(i=0; i<8; i++)
    {
        for(j=0; j<W_BHeight; j++)
        {
            pj=min(15,round((j/W_BHeight)*16));
            if(Wimg_Red[0][0]==Wimg_Red[i+96][pj+40+(32*W_BState)]&&Wimg_Green[0][0]==Wimg_Green[i+96][pj+40+(32*W_BState)]&&Wimg_Blue[0][0]==Wimg_Blue[i+96][pj+40+(32*W_BState)])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[i+96][pj+40+(32*W_BState)],Wimg_Green[i+96][pj+40+(32*W_BState)],Wimg_Blue[i+96][pj+40+(32*W_BState)],0,1);
                putpixel(i+W_Xo,j+W_Yo+8);
            }
        }
    }
}
void DB_BCC(int W_Xo, int W_Yo, int W_BState, float W_BWidth, float W_BHeight) //Button Center
{
    int i=0,j=0,pi=0,pj=0;
    if(W_BWidth>0&&W_BHeight>0)
    {
        for(i=0; i<W_BWidth; i++)
        {
            for(j=0; j<W_BHeight; j++)
            {
                pi=min(15,round((i/W_BWidth)*16));
                pj=min(15,round((j/W_BHeight)*16));
                setpen(Wimg_Red[pi+104][pj+40+(32*W_BState)],Wimg_Green[pi+104][pj+40+(32*W_BState)],Wimg_Blue[pi+104][pj+40+(32*W_BState)],0,1);
                putpixel(i+W_Xo+8,j+W_Yo+8);
            }
        }
    }
}
void DB_BRB(int W_Xo, int W_Yo, int W_BState, float W_BWidth, float W_BHeight) //Button Right Border
{
    int i=0,j=0,pj=0;
    for(i=0; i<8; i++)
    {
        for(j=0; j<W_BHeight; j++)
        {
            pj=min(15,round((j/W_BHeight)*16));
            if(Wimg_Red[0][0]==Wimg_Red[i+120][pj+40+(32*W_BState)]&&Wimg_Green[0][0]==Wimg_Green[i+120][pj+40+(32*W_BState)]&&Wimg_Blue[0][0]==Wimg_Blue[i+120][pj+40+(32*W_BState)])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[i+120][pj+40+(32*W_BState)],Wimg_Green[i+120][pj+40+(32*W_BState)],Wimg_Blue[i+120][pj+40+(32*W_BState)],0,1);
                putpixel(i+W_Xo+8+W_BWidth,j+W_Yo+8);
            }
        }
    }
}
void DB_BBoL(int W_Xo, int W_Yo, int W_BState, int W_BHeight) //Button Bottom Left (Corner)
{
    int i=0,j=0;
    for(i=0; i<8; i++)
    {
        for(j=0; j<8; j++)
        {
            if(Wimg_Red[0][0]==Wimg_Red[i+96][j+56+(32*W_BState)]&&Wimg_Green[0][0]==Wimg_Green[i+96][j+56+(32*W_BState)]&&Wimg_Blue[0][0]==Wimg_Blue[i+96][j+56+(32*W_BState)])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[i+96][j+56+(32*W_BState)],Wimg_Green[i+96][j+56+(32*W_BState)],Wimg_Blue[i+96][j+56+(32*W_BState)],0,1);
                putpixel(i+W_Xo,j+W_Yo+8+W_BHeight);
            }
        }
    }
}
void DB_BBB(int W_Xo, int W_Yo, int W_BState, float W_BWidth, int W_BHeight) //Button Bottom Border
{
    int i=0,j=0,pi=0;
    for(i=0; i<W_BWidth; i++)
    {
        for(j=0; j<8; j++)
        {
            pi=min(15,round((i/W_BWidth)*16));
            if(Wimg_Red[0][0]==Wimg_Red[pi+104][j+56+(32*W_BState)]&&Wimg_Green[0][0]==Wimg_Green[pi+104][j+56+(32*W_BState)]&&Wimg_Blue[0][0]==Wimg_Blue[pi+104][j+56+(32*W_BState)])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[pi+104][j+56+(32*W_BState)],Wimg_Green[pi+104][j+56+(32*W_BState)],Wimg_Blue[pi+104][j+56+(32*W_BState)],0,1);
                putpixel(i+W_Xo+8,j+W_Yo+W_BHeight+8);
            }
        }
    }
}
void DB_BBR(int W_Xo, int W_Yo, int W_BState, int W_BWidth,int W_BHeight) //Button Bottom Right (Corner)
{
    int i=0,j=0;
    for(i=0; i<8; i++)
    {
        for(j=0; j<8; j++)
        {
            if(Wimg_Red[0][0]==Wimg_Red[i+120][j+56+(32*W_BState)]&&Wimg_Green[0][0]==Wimg_Green[i+120][j+56+(32*W_BState)]&&Wimg_Blue[0][0]==Wimg_Blue[i+120][j+56+(32*W_BState)])
            {
                setpen(0,0,0,1,1);
            }
            else
            {
                setpen(Wimg_Red[i+120][j+56+(32*W_BState)],Wimg_Green[i+120][j+56+(32*W_BState)],Wimg_Blue[i+120][j+56+(32*W_BState)],0,1);
                putpixel(i+W_Xo+8+W_BWidth,j+W_Yo+8+W_BHeight);
            }
        }
    }
}
void DB_DrawButton(int Xo, int Yo, int BState, int BWidth, int BHeight, int W_Xr, int W_Yr)
{
    DB_BTL(Xo,Yo,BState);
    DB_BTB(Xo,Yo,BState,BWidth);
    DB_BTR(Xo,Yo,BState,BWidth);
    DB_BLB(Xo,Yo,BState,BHeight);
    DB_BCC(Xo,Yo,BState,BWidth,BHeight);
    DB_BRB(Xo,Yo,BState,BWidth,BHeight);
    DB_BBoL(Xo,Yo,BState,BHeight);
    DB_BBB(Xo,Yo,BState,BWidth,BHeight);
    DB_BBR(Xo,Yo,BState,BWidth,BHeight);
    x=(-parent.width/2)+10+(W_Xr*8);
    y=(-parent.height/2)+22+(W_Yr*16);
}


add that into global code, the import bitmap will work with it.

the functions to use are:
DW_Main(X offset , Y offset, active? (1 true, 0 false), working width (excluding the borders), working height (excluding the borders), resizable? (1 true, 0 false), draw border only? (1 false, 0 true. Why? it actually asks if it should draw working area :wink: )) Use this to draw the window

DW_SetTitle(X offset (This does nothing...), Y offset(This does nothing...), active? (This does nothing... I think I meant to add more functionality to these function), title of the window in "" 's) Use this on a text actor parented to it's corresponding window to position it in create actor

DW_SetMessage(X Offset (This does nothing...), Y Offset (This does nothing...), X smart offset (1=8 pixel), Y smart offset (1=16 pixel)) Use this on a text actor parented to it's corresponding window to position it in create actor

DW_DrawClose(X offset (This does nothing...), Y offset (This does nothing...), should be same as working width of current window, current state of button (0 normal, 1 hover, 2 pressed)) User this on a canvas actor parented to it's corresponding window to position it AND draw it

DB_DrawButton(X offset (This does nothing...), Y offset (This does nothing...), current state of button (0 normal, 1 hover, 2 pressed), width of middle of button, height of middle of button, X smart offset (1=8 pixel), Y smart offset (1=16 pixel)) Use this on a canvas actor parented to it's corresponding window to position it AND draw it

Now with these new settings including... you need a different layout in your bitmap, so here is a sample
WinSkin_Default.png
WinSkin_Default.png (10.4 KiB) Viewed 53378 times
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Bitmap window generator function

Postby Game A Gogo » Sat Apr 30, 2011 10:10 pm

template.PNG
template.PNG (982 Bytes) Viewed 53375 times

if you ever have problems with the size of elements!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score


Return to Game Demos

Who is online

Users browsing this forum: No registered users and 1 guest