mirror of
https://github.com/simtactics/niotso.git
synced 2025-07-04 13:47:05 -04:00
Fully functional cst parser.
New client code for Windows. The window does not appear until the OpenGL rendering context has completely initialized and (one day) has the first frame ready to draw.
This commit is contained in:
parent
b746dbe407
commit
8bb608d5ce
28 changed files with 897 additions and 107 deletions
|
@ -17,6 +17,7 @@ set(FILEHANDLER_MINOR 0)
|
|||
set(FILEHANDLER_SOURCES
|
||||
File.cpp
|
||||
Image.cpp
|
||||
cst/cst.c
|
||||
iff/chunks.c
|
||||
iff/iff.c
|
||||
)
|
||||
|
|
47
Libraries/FileHandler/cst/cst.c
Normal file
47
Libraries/FileHandler/cst/cst.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
cst.c - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "cst.h"
|
||||
|
||||
unsigned cst_count_strings(const char * Buffer, size_t FileSize){
|
||||
unsigned count = 0;
|
||||
int instring = 0;
|
||||
while(FileSize--){
|
||||
if(*Buffer == '^' && (instring = !instring) == 0)
|
||||
count++;
|
||||
Buffer++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int cst_read(CSTFile * CSTFileInfo, char * Buffer, size_t FileSize){
|
||||
CSTFileInfo->CSTData = Buffer;
|
||||
CSTFileInfo->StringCount = cst_count_strings(Buffer, FileSize);
|
||||
if(CSTFileInfo->StringCount != 0){
|
||||
unsigned i;
|
||||
CSTFileInfo->Strings = malloc(CSTFileInfo->StringCount * sizeof(char *));
|
||||
if(CSTFileInfo->Strings == NULL)
|
||||
return 0;
|
||||
for(i=0; i<CSTFileInfo->StringCount; i++){
|
||||
CSTFileInfo->Strings[i] = Buffer = strchr(Buffer, '^') + 1;
|
||||
*(Buffer = strchr(Buffer, '^')) = 0x00;
|
||||
Buffer++;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
21
Libraries/FileHandler/cst/cst.h
Normal file
21
Libraries/FileHandler/cst/cst.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
cst.h - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
char * CSTData;
|
||||
unsigned StringCount;
|
||||
char ** Strings;
|
||||
} CSTFile;
|
|
@ -32,7 +32,7 @@ int main(int argc, char *argv[]){
|
|||
IFFChunkNode * ChunkNode;
|
||||
|
||||
if(argc == 1 || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")){
|
||||
printf("Usage: iffexport [-f] infile OutDirectory\n"
|
||||
printf("Usage: iffexport [-f] infile outdirectory\n"
|
||||
"Export the resources of an EA IFF file.\n"
|
||||
"Use -f to force overwriting without confirmation.\n"
|
||||
"\n"
|
||||
|
|
15
Libraries/FileHandler/uis/uis.c
Normal file
15
Libraries/FileHandler/uis/uis.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
uis.c - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
32
Libraries/FileHandler/uis/uis.h
Normal file
32
Libraries/FileHandler/uis/uis.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
uis.h - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
enum UISTagType {
|
||||
UIS_Type_Button,
|
||||
UIS_Type_FormattedText,
|
||||
UIS_Type_ListBox,
|
||||
UIS_Type_ProgressBar,
|
||||
UIS_Type_Slider,
|
||||
UIS_Type_Text,
|
||||
UIS_Type_TextEdit,
|
||||
UIS_Type_Image,
|
||||
UIS_Type_String,
|
||||
UIS_Type_Custom
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
UISTagType TagType;
|
||||
} UISTag;
|
|
@ -49,7 +49,7 @@ uint8_t UTKTable2[512];
|
|||
const uint8_t UTKTable3[29] = {8,7,8,7,2,2,2,3,3,4,4,3,3,5,5,4,4,6,6,5,5,7,7,6,6,8,8,7,7};
|
||||
float UTKTable4[29];
|
||||
|
||||
int utk_read_header(utkheader_t * UTKHeader, const uint8_t * Buffer, unsigned FileSize)
|
||||
int utk_read_header(utkheader_t * UTKHeader, const uint8_t * Buffer, size_t FileSize)
|
||||
{
|
||||
if(FileSize < 28) return 0;
|
||||
memcpy(&UTKHeader->sID, Buffer, 4);
|
||||
|
|
|
@ -45,9 +45,9 @@
|
|||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glext.h>
|
||||
#include <gl/gl.h>
|
||||
#include <gl/glu.h>
|
||||
#include <gl/glext.h>
|
||||
#include <FileHandler.hpp>
|
||||
#include "libvitaboy.hpp"
|
||||
|
||||
|
@ -538,7 +538,7 @@ BOOL CreateGLWindow(const char * title, int width, int height, int bits, bool fu
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!SetPixelFormat(hDC,PixelFormat, &pfd)){
|
||||
if(!SetPixelFormat(hDC, PixelFormat, &pfd)){
|
||||
KillGLWindow();
|
||||
MessageBox(NULL, "Can't set the PixelFormat.", NULL, MB_OK | MB_ICONERROR);
|
||||
return false;
|
||||
|
@ -553,11 +553,11 @@ BOOL CreateGLWindow(const char * title, int width, int height, int bits, bool fu
|
|||
|
||||
if(!wglMakeCurrent(hDC, hRC)){
|
||||
KillGLWindow();
|
||||
MessageBox(NULL, "Failed to activate an OpenGL device context.", NULL, MB_OK | MB_ICONERROR);
|
||||
MessageBox(NULL, "Failed to activate the OpenGL device context.", NULL, MB_OK | MB_ICONERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
ShowWindow(hWnd,SW_SHOW);
|
||||
ShowWindow(hWnd, SW_SHOW);
|
||||
SetForegroundWindow(hWnd);
|
||||
SetFocus(hWnd);
|
||||
ResizeScene(width, height);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue