#if defined(UNICODE) && !defined(_UNICODE)
#define _UNICODE
#elif defined(_UNICODE) && !defined(UNICODE)
#define UNICODE
#endif
#include <windows.h>
#include <cstdlib>
#include <time.h>
#include <ctime>
#include <string>
#include <sstream>
#include <SFML/Graphics.hpp>
// Define variables that hold the ID of the windows and buttons we will hide and show
// Button IDs
#define ms_but 1
#define in_but 2
#define dx_but 3
#define ps_but 4
#define ch_but 5
#define cn_but 6
#define TextBut 29
//Attribute window IDs
#define ms 7
#define in 8
#define dx 9
#define ps 10
#define ch 11
#define cn 12
#define ms_updater 13
#define in_updater 14
#define dx_updater 15
#define ps_updater 16
#define ch_updater 17
#define cn_updater 18
//menu IDs
#define SaveCharButton 19
#define ExitButton 20
#define CharType1 21
#define CharType2 22
#define CharType3 23
#define AnimType1 24
//Misc Text IDs
#define Purestrn 25
#define MutHum 26
#define MutAnim 27
#define customAnim 29
//Edit Box IDs
#define AnimEdit 28
//current top number for IDs = 30
/******************************GLOBAL VARIABLES***********************************************************************************/
int ms_num = 0;
int in_num = 0;
int dx_num = 0;
int ps_num = 0;
int ch_num = 0;
int cn_num = 0;
// Create storage for the dice (for use in a later update)
int die1;
int die2;
int die3;
int die4;
clock_t clkms=clock();
//strings for textboxes
std::string AnimText;
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "WindowsApp";
//converts integers
std::string String ( double Val ) {
std::ostringstream Stream;
Stream << Val;
return Stream.str ( );
}
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Charactor Creater", /* Title Text */
WS_SYSMENU, /* Style of window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
900, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
//create the sfml window... can we control both at once?
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
UpdateWindow(hwnd);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HMENU hmenubar = CreateMenu();
HMENU hfile = CreateMenu();
HMENU hcharacter = CreateMenu();
HMENU Types = CreateMenu();
//HMENU AnimTypes =CreateMenu();
switch (message) /* handle the messages */
{
/************************************This is where the inside stuff is programmed***************************************************/
// declare menu
case WM_CREATE:{// where things are created at start.
//setup menu
AppendMenu (hmenubar,MF_POPUP, (UINT_PTR) hfile ,"File" );
AppendMenu (hfile, MF_STRING, ExitButton, "Exit");
AppendMenu (hmenubar, MF_POPUP, (UINT_PTR)hcharacter, "Character");
AppendMenu (hcharacter, MF_POPUP|MF_STRING, SaveCharButton, "Save Character");
AppendMenu (hcharacter, MF_POPUP|MF_STRING, (UINT_PTR)Types, "Character Type");
AppendMenu (Types, MF_POPUP |MF_STRING, CharType1, "Pure Strain Human");
AppendMenu (Types, MF_POPUP |MF_STRING, CharType2, "Mutated Human");
AppendMenu (Types, MF_POPUP |MF_STRING, CharType3, "Mutated Animal");
// display menu
SetMenu(hwnd, hmenubar);
//edit boxes*************************************************************************************************************************
CreateWindow(TEXT("EDIT"), TEXT("Animal Type"),
WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL,
400,// X
20,// Y
80,// width
17,// hight
hwnd,
(HMENU) AnimEdit,
NULL,
NULL);
//Misc text
CreateWindow(TEXT("static"), TEXT("Attributes"),
WS_VISIBLE | WS_CHILD,
20,// X
20,// Y
90,// width
30,// hight
hwnd,
(HMENU) NULL,
NULL,
NULL);
CreateWindow(TEXT("static"), TEXT("Character Type:"),
WS_VISIBLE | WS_CHILD,
140,// X
20,// Y
110,// width
30,// hight
hwnd,
(HMENU) NULL,
NULL,
NULL);
/*************************BASE NUMBERS*******************************************************************************************************/
CreateWindow(TEXT("STATIC"),String(ms_num).c_str (),
WS_VISIBLE | WS_CHILD,
40,// X
60,// Y
10,// width
25,// hight
hwnd, //designate the parent window
(HMENU) ms,
NULL,
NULL);
CreateWindow(TEXT("STATIC"),String(in_num).c_str (),
WS_VISIBLE | WS_CHILD,
40,// X
90,// Y
10,// width
25,// hight
hwnd, //designate the parent window
(HMENU) in,
NULL,
NULL);
CreateWindow(TEXT("STATIC"),String(dx_num).c_str (),
WS_VISIBLE | WS_CHILD,
40,// X
120,// Y
10,// width
25,// hight
hwnd, //designate the parent window
(HMENU) dx,
NULL,
NULL);
CreateWindow(TEXT("STATIC"),String(ps_num).c_str (),
WS_VISIBLE | WS_CHILD,
40,// X
150,// Y
10,// width
25,// hight
hwnd, //designate the parent window
(HMENU) ps,
NULL,
NULL);
CreateWindow(TEXT("STATIC"),String(ch_num).c_str (),
WS_VISIBLE | WS_CHILD,
40,// X
180,// Y
10,// width
25,// hight
hwnd, //designate the parent window
(HMENU) ch,
NULL,
NULL);
CreateWindow(TEXT("static"), String(cn_num).c_str (), //type ShowWindow(handle,SW_HIDE) to hide
WS_VISIBLE |WS_CHILD,
40,// X
210,// Y
10,// width
20,// hight
hwnd,
(HMENU) cn,
NULL,
NULL);
/**********************************************************************************************************************************************/
/************************************ATTRIBUTE NAMES***********************************************************************************************/
CreateWindow(TEXT("static"), TEXT("MS"),//mental strength
WS_VISIBLE | WS_CHILD| WS_BORDER,
10,// X
60,// Y
25,// width
20,// hight
hwnd,
(HMENU) NULL,
NULL,
NULL);
CreateWindow(TEXT("static"), TEXT("IN"),
WS_VISIBLE | WS_CHILD| WS_BORDER,
10,// X
90,// Y
25,// width
20,// hight
hwnd,
(HMENU) NULL,
NULL,
NULL);
CreateWindow(TEXT("static"), TEXT("DX"),
WS_VISIBLE | WS_CHILD| WS_BORDER,
10,// X
120,// Y
25,// width
20,// hight
hwnd,
(HMENU) NULL,
NULL,
NULL);
CreateWindow(TEXT("static"), TEXT("PS"),
WS_VISIBLE | WS_CHILD| WS_BORDER,
10,// X
150,// Y
25,// width
20,// hight
hwnd,
(HMENU) NULL,
NULL,
NULL);
CreateWindow(TEXT("static"), TEXT("CH"),
WS_VISIBLE | WS_CHILD| WS_BORDER,
10,// X
180,// Y
25,// width
20,// hight
hwnd,
(HMENU) NULL,
NULL,
NULL);
CreateWindow(TEXT("static"), TEXT("CN"),
WS_VISIBLE | WS_CHILD| WS_BORDER,
10,// X
210,// Y
25,// width
20,// hight
hwnd,
(HMENU) NULL,
NULL,
NULL);
//Button Code**************************************************************************************************************************************/
CreateWindow(TEXT("button"),
TEXT("Enter"),
WS_VISIBLE | WS_CHILD,
445, //X
40, //Y
40, //width
17, //hight
hwnd,
(HMENU) TextBut,
NULL,
NULL
);
// create a window for a button using the ungodly 11 perameter built in create window function >.>
CreateWindow(TEXT("button"),// the type of window we want to use
TEXT("Roll"),// the text we want displayed on our button
WS_VISIBLE | WS_CHILD, /* is initially visible*///creates a child window //types of windows styles needed for our window See http://msdn.microsoft.com/en-us/library/czada357.aspx 10, //x position
70, //X position
60, //Y position
35, //width
20, //hight
hwnd, // handle of the parent window
(HMENU) ms_but, //value that specifies the window we are creating
NULL,// don't know what this does
NULL// don't know what this does either
);
//once created get the handles
CreateWindow(TEXT("button"),
TEXT("Roll"),
WS_VISIBLE | WS_CHILD,
70, //X
90, //Y
35, //width
20, //hight
hwnd,
(HMENU) in_but,
NULL,
NULL
);
CreateWindow(TEXT("button"),
TEXT("Roll"),
WS_VISIBLE | WS_CHILD,
70, //X
120, //Y
35, //width
20, //hight
hwnd,
(HMENU) dx_but,
NULL,
NULL
);
CreateWindow(TEXT("button"),
TEXT("Roll"),
WS_VISIBLE | WS_CHILD,
70, //X
150, //Y
35, //width
20, //hight
hwnd,
(HMENU) ps_but,
NULL,
NULL
);
CreateWindow(TEXT("button"),
TEXT("Roll"),
WS_VISIBLE | WS_CHILD,
70, //X
180, //Y
35, //width
20, //hight
hwnd,
(HMENU) ch_but,
NULL,
NULL
);
CreateWindow(TEXT("button"),
TEXT("Roll"),
WS_VISIBLE | WS_CHILD,
70, //X
210, //Y
35, //width
20, //hight
hwnd,
(HMENU) cn_but,
NULL,
NULL
);
break;
}
// this is where you program what happens when we interact with the stuff we have created
case WM_COMMAND:{
//If Exit button is pressed
if (LOWORD(wParam) == ExitButton){
PostQuitMessage (0);
}
if (LOWORD(wParam) == TextBut){
char szInput[1024];//max input of 1024 chars
// Obtains input from the textbox and puts it into the char array
GetWindowText(GetDlgItem(hwnd, AnimEdit), szInput, 1024);
CreateWindow(TEXT("STATIC"),szInput,
WS_VISIBLE | WS_CHILD,
400,// X
20,// Y
100,// width
20,// hight
hwnd, //designate the parent window
(HMENU) customAnim,// ID
NULL,
NULL);
}
//Menu Code***********************************************************************************************************************************************************************
if (LOWORD(wParam) == CharType1){
CreateWindow(TEXT("STATIC"),"Pure Strain Human",
WS_VISIBLE | WS_CHILD,
250,// X
20,// Y
125,// width
30,// hight
hwnd, //designate the parent window
(HMENU) Purestrn,// ID
NULL,
NULL);
ShowWindow(GetDlgItem(hwnd,Purestrn),SW_SHOW);
}
if (LOWORD(wParam) == CharType2){
CreateWindow(TEXT("STATIC"),"Mutated Human",
WS_VISIBLE | WS_CHILD,
250,// X
20,// Y
125,// width
30,// hight
hwnd, //designate the parent window
(HMENU) MutHum,// ID
NULL,
NULL);
ShowWindow(GetDlgItem(hwnd,MutHum),SW_SHOW);
}
if (LOWORD(wParam) == CharType3){
CreateWindow(TEXT("STATIC"),"Mutated Animal:",
WS_VISIBLE | WS_CHILD,
250,// X
20,// Y
125,// width
30,// hight
hwnd, //designate the parent window
(HMENU) MutAnim,// ID
NULL,
NULL);
ShowWindow(GetDlgItem(hwnd,MutAnim),SW_SHOW);
}
// Atribute button code**********************************************************************************************************************************************************
if (LOWORD(wParam) == ms_but){// If window 1 (the button) has been clicked
ShowWindow(GetDlgItem(hwnd,ms),SW_HIDE); //hide the previous number
int roll;//create a variable to hold our random number
srand(clock()-clkms);// seed the rand function with time NOTE: will only change result every second
roll= 3+(rand()%16);// creat a random number between 1-18 NOTE: rand will always count upwards until the limit is reached and then start low again. too predictable
ms_num = roll;
CreateWindow(TEXT("STATIC"),String(ms_num).c_str (),
WS_VISIBLE | WS_CHILD,
40,// X
60,// Y
25,// width
25,// hight
hwnd, //designate the parent window
(HMENU) ms_updater,
NULL,
NULL);
ShowWindow(GetDlgItem(hwnd,ms_updater),SW_SHOW);
ShowWindow(GetDlgItem(hwnd,ms_but),SW_HIDE);
/* This creates a random number and shows it in a pop-up. im doing things differently but im a pack rat so >.>
int roll;
srand(time(0));
roll= 1+(rand()%6);
MessageBoxA(hwnd, String(roll).c_str () ,"Your roll", MB_OK); // show a message
*/
}
if (LOWORD(wParam) == in_but){// If window 1 (the button) has been clicked
ShowWindow(GetDlgItem(hwnd,in),SW_HIDE); //hide the previous number
//calculate roll
int roll;//create a variable to hold our random number
srand(clock()-clkms);// seed the rand function with time NOTE: will only change result every second
roll= 3+(rand()%16);// creat a random number between 1-18 NOTE: rand will always count upwards until the limit is reached and then start low again. too predictable
in_num = roll;
CreateWindow(TEXT("STATIC"),String(in_num).c_str (),
WS_VISIBLE | WS_CHILD,
40,// X
90,// Y
25,// width
25,// hight
hwnd, //designate the parent window
(HMENU) in_updater,
NULL,
NULL);
ShowWindow(GetDlgItem(hwnd,in_updater),SW_SHOW);
ShowWindow(GetDlgItem(hwnd,in_but),SW_HIDE);
}
if (LOWORD(wParam) == dx_but){// If window 1 (the button) has been clicked
ShowWindow(GetDlgItem(hwnd,dx),SW_HIDE); //hide the previous number
//calculate roll
int roll;//create a variable to hold our random number
srand(clock()-clkms);// seed the rand function with time NOTE: will only change result every second
roll= 3+(rand()%16);// creat a random number between 1-18 NOTE: rand will always count upwards until the limit is reached and then start low again. too predictable
dx_num = roll;
CreateWindow(TEXT("STATIC"),String(dx_num).c_str (),
WS_VISIBLE | WS_CHILD,
40,// X
120,// Y
25,// width
25,// hight
hwnd, //designate the parent window
(HMENU) dx_updater,
NULL,
NULL);
ShowWindow(GetDlgItem(hwnd,dx_updater),SW_SHOW);
ShowWindow(GetDlgItem(hwnd,dx_but),SW_HIDE);
}
if (LOWORD(wParam) == ps_but){// If window 1 (the button) has been clicked
ShowWindow(GetDlgItem(hwnd,ps),SW_HIDE); //hide the previous number
//calculate roll
int roll;//create a variable to hold our random number
srand(clock()-clkms);// seed the rand function with time NOTE: will only change result every second
roll= 3+(rand()%16);// creat a random number between 1-18 NOTE: rand will always count upwards until the limit is reached and then start low again. too predictable
ps_num = roll;
CreateWindow(TEXT("STATIC"),String(ps_num).c_str (),
WS_VISIBLE | WS_CHILD,
40,// X
150,// Y
25,// width
25,// hight
hwnd, //designate the parent window
(HMENU) ps_updater,
NULL,
NULL);
ShowWindow(GetDlgItem(hwnd,ps_updater),SW_SHOW);
ShowWindow(GetDlgItem(hwnd,ps_but),SW_HIDE);
}
if (LOWORD(wParam) == ch_but){// If window 1 (the button) has been clicked
ShowWindow(GetDlgItem(hwnd,ch),SW_HIDE); //hide the previous number
//calculate roll
int roll;//create a variable to hold our random number
srand(clock()-clkms);// seed the rand function with time NOTE: will only change result every second
roll= 3+(rand()%16);// creat a random number between 1-18 NOTE: rand will always count upwards until the limit is reached and then start low again. too predictable
ch_num = roll;
CreateWindow(TEXT("STATIC"),String(ch_num).c_str (),
WS_VISIBLE | WS_CHILD,
40,// X
180,// Y
25,// width
25,// hight
hwnd, //designate the parent window
(HMENU) ch_updater,
NULL,
NULL);
ShowWindow(GetDlgItem(hwnd,ch_updater),SW_SHOW);
ShowWindow(GetDlgItem(hwnd,ch_but),SW_HIDE);
}
if (LOWORD(wParam) == cn_but){// If window 1 (the button) has been clicked
ShowWindow(GetDlgItem(hwnd,cn),SW_HIDE); //hide the previous number
//calculate roll
int roll;//create a variable to hold our random number
srand(clock()-clkms);// seed the rand function with time NOTE: will only change result every second
roll= 3+(rand()%16);// creat a random number between 1-18 NOTE: rand will always count upwards until the limit is reached and then start low again. too predictable
cn_num = roll;
CreateWindow(TEXT("STATIC"),String(cn_num).c_str (),
WS_VISIBLE | WS_CHILD,
40,// X
210,// Y
25,// width
25,// hight
hwnd, //designate the parent window
(HMENU) cn_updater,
NULL,
NULL);
ShowWindow(GetDlgItem(hwnd,cn_updater),SW_SHOW);
ShowWindow(GetDlgItem(hwnd,cn_but),SW_HIDE);
}
break;}
// this is where we program what happens when we close the window
case WM_DESTROY: // if x button is pressed
PostQuitMessage (0); /* send a WM_QUIT to the message queue to kill the process*/
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}