mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-16 05:14:01 +02:00
Visual Studio fixes
This commit is contained in:
committed by
Simon Robertshaw
parent
04b3eb11fd
commit
36e2a07a5b
@@ -1,5 +1,5 @@
|
|||||||
editor: editor.c
|
editor: editor.c
|
||||||
gcc -oeditor -DSCALE=2 editor.c -lSDL -lm -O3 -ffast-math -march=k8 -Wall -std=c99
|
gcc -oeditor -DSCALE=2 -DFONTEDITOR editor.c -lSDL -lm -O3 -ffast-math -march=k8 -Wall -std=c99
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f editor packer
|
rm -f editor packer
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
#ifdef FONTEDITOR
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -282,3 +284,5 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
#ifdef FONTEDITOR
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -98,3 +100,5 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@@ -112,6 +112,12 @@ typedef unsigned int pixel;
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define strcasecmp stricmp
|
#define strcasecmp stricmp
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(WIN32) && !defined(__GNUC__)
|
||||||
|
#define fmin min
|
||||||
|
#define fminf min
|
||||||
|
#define fmax max
|
||||||
|
#define fmaxf max
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SDEUT
|
#define SDEUT
|
||||||
|
|
||||||
|
@@ -163,7 +163,8 @@ pixel *resample_img(pixel *src, int sw, int sh, int rw, int rh)
|
|||||||
q = malloc(rw*rh*PIXELSIZE);
|
q = malloc(rw*rh*PIXELSIZE);
|
||||||
memcpy(q, src, rw*rh*PIXELSIZE);
|
memcpy(q, src, rw*rh*PIXELSIZE);
|
||||||
} else if(rw > sw && rh > sh){
|
} else if(rw > sw && rh > sh){
|
||||||
float fx, fy, fyc, fxc, intp;
|
float fx, fy, fyc, fxc;
|
||||||
|
double intp;
|
||||||
pixel tr, tl, br, bl;
|
pixel tr, tl, br, bl;
|
||||||
q = malloc(rw*rh*PIXELSIZE);
|
q = malloc(rw*rh*PIXELSIZE);
|
||||||
//Bilinear interpolation for upscaling
|
//Bilinear interpolation for upscaling
|
||||||
@@ -172,8 +173,8 @@ pixel *resample_img(pixel *src, int sw, int sh, int rw, int rh)
|
|||||||
{
|
{
|
||||||
fx = ((float)x)*((float)sw)/((float)rw);
|
fx = ((float)x)*((float)sw)/((float)rw);
|
||||||
fy = ((float)y)*((float)sh)/((float)rh);
|
fy = ((float)y)*((float)sh)/((float)rh);
|
||||||
fxc = modff(fx, &intp);
|
fxc = modf(fx, &intp);
|
||||||
fyc = modff(fy, &intp);
|
fyc = modf(fy, &intp);
|
||||||
fxceil = (int)ceil(fx);
|
fxceil = (int)ceil(fx);
|
||||||
fyceil = (int)ceil(fy);
|
fyceil = (int)ceil(fy);
|
||||||
if (fxceil>=sw) fxceil = sw-1;
|
if (fxceil>=sw) fxceil = sw-1;
|
||||||
@@ -190,7 +191,8 @@ pixel *resample_img(pixel *src, int sw, int sh, int rw, int rh)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//Stairstepping
|
//Stairstepping
|
||||||
float fx, fy, fyc, fxc, intp;
|
float fx, fy, fyc, fxc;
|
||||||
|
double intp;
|
||||||
pixel tr, tl, br, bl;
|
pixel tr, tl, br, bl;
|
||||||
int rrw = rw, rrh = rh;
|
int rrw = rw, rrh = rh;
|
||||||
pixel * oq;
|
pixel * oq;
|
||||||
@@ -212,8 +214,8 @@ pixel *resample_img(pixel *src, int sw, int sh, int rw, int rh)
|
|||||||
{
|
{
|
||||||
fx = ((float)x)*((float)sw)/((float)rw);
|
fx = ((float)x)*((float)sw)/((float)rw);
|
||||||
fy = ((float)y)*((float)sh)/((float)rh);
|
fy = ((float)y)*((float)sh)/((float)rh);
|
||||||
fxc = modff(fx, &intp);
|
fxc = modf(fx, &intp);
|
||||||
fyc = modff(fy, &intp);
|
fyc = modf(fy, &intp);
|
||||||
fxceil = (int)ceil(fx);
|
fxceil = (int)ceil(fx);
|
||||||
fyceil = (int)ceil(fy);
|
fyceil = (int)ceil(fy);
|
||||||
if (fxceil>=sw) fxceil = sw-1;
|
if (fxceil>=sw) fxceil = sw-1;
|
||||||
|
@@ -16,7 +16,11 @@
|
|||||||
#include <misc.h>
|
#include <misc.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
#include <images.h>
|
#include <images.h>
|
||||||
|
#if defined(WIN32) && !defined(__GNUC__)
|
||||||
|
#include <io.h>
|
||||||
|
#else
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
SDLMod sdl_mod;
|
SDLMod sdl_mod;
|
||||||
int sdl_key, sdl_wheel, sdl_caps=0, sdl_ascii, sdl_zoom_trig=0;
|
int sdl_key, sdl_wheel, sdl_caps=0, sdl_ascii, sdl_zoom_trig=0;
|
||||||
@@ -5109,9 +5113,26 @@ typedef struct savelist_e savelist_e;
|
|||||||
savelist_e *get_local_saves(char *folder, char *search, int *results_ret)
|
savelist_e *get_local_saves(char *folder, char *search, int *results_ret)
|
||||||
{
|
{
|
||||||
int index = 0, results = 0;
|
int index = 0, results = 0;
|
||||||
struct dirent *derp;
|
|
||||||
savelist_e *new_savelist = NULL;
|
savelist_e *new_savelist = NULL;
|
||||||
savelist_e *current_item = NULL;
|
savelist_e *current_item = NULL, *new_item = NULL;
|
||||||
|
char *fname;
|
||||||
|
#if defined(WIN32) && !defined(__GNUC__)
|
||||||
|
struct _finddata_t current_file;
|
||||||
|
intptr_t findfile_handle;
|
||||||
|
char *filematch = malloc(strlen(folder)+4);
|
||||||
|
sprintf(filematch, "%s%s", folder, "*.*");
|
||||||
|
findfile_handle = _findfirst(filematch, ¤t_file);
|
||||||
|
free(filematch);
|
||||||
|
if (findfile_handle == -1L)
|
||||||
|
{
|
||||||
|
*results_ret = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
do
|
||||||
|
{
|
||||||
|
fname = current_file.name;
|
||||||
|
#else
|
||||||
|
struct dirent *derp;
|
||||||
DIR *directory = opendir(folder);
|
DIR *directory = opendir(folder);
|
||||||
if(!directory)
|
if(!directory)
|
||||||
{
|
{
|
||||||
@@ -5119,39 +5140,40 @@ savelist_e *get_local_saves(char *folder, char *search, int *results_ret)
|
|||||||
*results_ret = 0;
|
*results_ret = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
while(derp = readdir(directory)){
|
while(derp = readdir(directory))
|
||||||
char *ext;
|
{
|
||||||
if(strlen(derp->d_name)>4)
|
fname = derp->d_name;
|
||||||
|
#endif
|
||||||
|
if(strlen(fname)>4)
|
||||||
{
|
{
|
||||||
ext = derp->d_name+(strlen(derp->d_name)-4);
|
char *ext = fname+(strlen(fname)-4);
|
||||||
if((!strncmp(ext, ".cps", 4) || !strncmp(ext, ".stm", 4)) && (search==NULL || strstr(derp->d_name, search)))
|
if((!strncmp(ext, ".cps", 4) || !strncmp(ext, ".stm", 4)) && (search==NULL || strstr(fname, search)))
|
||||||
{
|
{
|
||||||
|
new_item = malloc(sizeof(savelist_e));
|
||||||
|
new_item->filename = malloc(strlen(folder)+strlen(fname)+1);
|
||||||
|
sprintf(new_item->filename, "%s%s", folder, fname);
|
||||||
|
new_item->name = mystrdup(fname);
|
||||||
|
new_item->image = NULL;
|
||||||
|
new_item->next = NULL;
|
||||||
if(new_savelist==NULL){
|
if(new_savelist==NULL){
|
||||||
new_savelist = malloc(sizeof(savelist_e));
|
new_savelist = new_item;
|
||||||
new_savelist->filename = malloc(strlen(folder)+strlen(derp->d_name)+1);
|
new_item->prev = NULL;
|
||||||
sprintf(new_savelist->filename, "%s%s", folder, derp->d_name);
|
|
||||||
new_savelist->name = mystrdup(derp->d_name);
|
|
||||||
new_savelist->image = NULL;
|
|
||||||
new_savelist->next = NULL;
|
|
||||||
new_savelist->prev = NULL;
|
|
||||||
current_item = new_savelist;
|
|
||||||
} else {
|
} else {
|
||||||
savelist_e *prev_item = current_item;
|
current_item->next = new_item;
|
||||||
current_item->next = malloc(sizeof(savelist_e));
|
new_item->prev = current_item;
|
||||||
current_item = current_item->next;
|
|
||||||
current_item->filename = malloc(strlen(folder)+strlen(derp->d_name)+1);
|
|
||||||
sprintf(current_item->filename, "%s%s", folder, derp->d_name);
|
|
||||||
current_item->name = mystrdup(derp->d_name);
|
|
||||||
current_item->image = NULL;
|
|
||||||
current_item->next = NULL;
|
|
||||||
current_item->prev = prev_item;
|
|
||||||
}
|
}
|
||||||
|
current_item = new_item;
|
||||||
results++;
|
results++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*results_ret = results;
|
#if defined(WIN32) && !defined(__GNUC__)
|
||||||
|
while (_findnext(findfile_handle, ¤t_file) == 0);
|
||||||
|
_findclose(findfile_handle);
|
||||||
|
#else
|
||||||
closedir(directory);
|
closedir(directory);
|
||||||
|
#endif
|
||||||
|
*results_ret = results;
|
||||||
return new_savelist;
|
return new_savelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5306,6 +5328,7 @@ void catalogue_ui(pixel * vid_buf)
|
|||||||
float scrollvel, offsetf = 0.0f;
|
float scrollvel, offsetf = 0.0f;
|
||||||
char savetext[128] = "";
|
char savetext[128] = "";
|
||||||
char * last = mystrdup("");
|
char * last = mystrdup("");
|
||||||
|
savelist_e *saves, *cssave, *csave;
|
||||||
ui_edit ed;
|
ui_edit ed;
|
||||||
|
|
||||||
vid_buf2 = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
|
vid_buf2 = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
|
||||||
@@ -5321,9 +5344,8 @@ void catalogue_ui(pixel * vid_buf)
|
|||||||
ed.nx = 0;
|
ed.nx = 0;
|
||||||
strcpy(ed.str, "");
|
strcpy(ed.str, "");
|
||||||
|
|
||||||
savelist_e *saves = get_local_saves(LOCAL_SAVE_DIR PATH_SEP, NULL, &rescount);
|
saves = get_local_saves(LOCAL_SAVE_DIR PATH_SEP, NULL, &rescount);
|
||||||
savelist_e *cssave = saves;
|
cssave = csave = saves;
|
||||||
savelist_e *csave = saves;
|
|
||||||
while (!sdl_poll())
|
while (!sdl_poll())
|
||||||
{
|
{
|
||||||
b = SDL_GetMouseState(&mx, &my);
|
b = SDL_GetMouseState(&mx, &my);
|
||||||
|
Reference in New Issue
Block a user