pax_global_header00006660000000000000000000000064143271450260014516gustar00rootroot0000000000000052 comment=b522752e1bbbc0d654347d81608685972e5f8f3f fanwor-1.16/000077500000000000000000000000001432714502600127415ustar00rootroot00000000000000fanwor-1.16/.gitignore000066400000000000000000000000311432714502600147230ustar00rootroot00000000000000*.o fanwor fawned/fawned fanwor-1.16/Makefile000066400000000000000000000001021432714502600143720ustar00rootroot00000000000000 all: $(MAKE) -C src clean: $(RM) fanwor $(MAKE) -C src clean fanwor-1.16/fawned/000077500000000000000000000000001432714502600142055ustar00rootroot00000000000000fanwor-1.16/fawned/Makefile000066400000000000000000000012751432714502600156520ustar00rootroot00000000000000#Makefile for "FAWNED - The FANWOR EDITOR" OBS=fedinit.o fedgraf.o fedkeys.o feddisk.o fedmain.o \ sdlgui.o dlgAlert.o dlgFileSelect.o file.o FWOBS=../src/fwdata.o ../src/arch/sdl/loadpng.o CFLAGS = -g -O1 -Wall $(shell sdl-config --cflags) CPPFLAGS = -I../src -I../src/arch/sdl LIBS = -lpng $(shell sdl-config --libs) fawned: $(OBS) $(FWOBS) $(CC) $(OBS) $(FWOBS) $(LIBS) -o fawned fedinit.o: feddefs.h fedmain.h fedgraf.h fedgraf.o: fedgraf.c feddefs.h fedmain.h ../src/fwdata.c ../src/fwdefs.h fedkeys.o: fedmain.h fedmain.o: fedmain.c feddefs.h fedinit.h fedgraf.h ../src/level.h ../src/fwdefs.h feddisk.o: ../src/level.h $(FWOBS): $(MAKE) -C ../src clean: $(RM) fawned *.o *.bak fanwor-1.16/fawned/dlgAlert.c000066400000000000000000000131071432714502600161110ustar00rootroot00000000000000/* * Hatari - dlgAlert.c - AES-like AlertBox * * Based on dlgAlert.cpp from the emulator ARAnyM, * Copyright (c) 2004 Petr Stehlik of ARAnyM dev team * * Adaptation to Hatari by Thomas Huth. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This file is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License (gpl.txt) for more details. */ const char DlgAlert_fileid[] = "Hatari dlgAlert.c : " __DATE__ " " __TIME__; #include #include #include #include "sdlgui.h" extern SDL_Surface *sdlscrn; #define MAX_LINES 4 static char dlglines[MAX_LINES][50+1]; #define DLGALERT_OK 5 #define DLGALERT_CANCEL 6 /* The "Alert"-dialog: */ static SGOBJ alertdlg[] = { { SGBOX, 0, 0, 0,0, 52,7, NULL }, { SGTEXT, 0, 0, 1,1, 50,1, dlglines[0] }, { SGTEXT, 0, 0, 1,2, 50,1, dlglines[1] }, { SGTEXT, 0, 0, 1,3, 50,1, dlglines[2] }, { SGTEXT, 0, 0, 1,4, 50,1, dlglines[3] }, { SGBUTTON, SG_DEFAULT, 0, 5,5, 8,1, "OK" }, { SGBUTTON, SG_CANCEL, 0, 24,5, 8,1, "Cancel" }, { -1, 0, 0, 0,0, 0,0, NULL } }; /*-----------------------------------------------------------------------*/ /** * Breaks long string to several strings of max_width, divided by '\0', * sets text_width to the longest line width and returns the number of lines * you need to display the strings. */ static int DlgAlert_FormatTextToBox(char *text, int max_width, int *text_width) { int columns = 0; int lines = 1; int txtlen; char *p; /* pointer to begin of actual line */ char *q; /* pointer to start of next search */ char *llb; /* pointer to last place suitable for breaking the line */ char *txtend; /* pointer to end of the text */ txtlen = strlen(text); q = p = text; llb = text-1; /* pointer to last line break */ txtend = text + txtlen; if (txtlen <= max_width) { *text_width = txtlen; return lines; } while(q < txtend) /* q was last place suitable for breaking */ { char *r = strpbrk(q, " \t/\\\n"); /* find next suitable place for the break */ if (r == NULL) r = txtend; /* if there's no place then point to the end */ if ((r-p) <= max_width && *r != '\n') /* '\n' is always used for breaking */ { llb = r; /* remember new place suitable for breaking */ q++; if ((r-p) > columns) columns = r - p; continue; /* search again */ } if ((r-p) > max_width) /* too long line already? */ { if (p > llb) /* bad luck - no place for the delimiter. Let's do it the strong way */ llb = p + max_width; /* we loose one character */ } else llb = r; /* break from previous delimiter */ *llb = '\0'; /* BREAK */ if ((llb-p) > columns) columns = llb - p; /* longest line so far */ p = q = llb + 1; /* next line begins here */ lines++; /* increment line counter */ } *text_width = columns; return lines; /* return line counter */ } /*-----------------------------------------------------------------------*/ /** * Show the "alert" dialog. Return true if user pressed "OK". */ static int DlgAlert_ShowDlg(const char *text) { static int maxlen = sizeof(dlglines[0])-1; char *t = (char *)malloc(strlen(text)+1); char *orig_t = t; int lines, i, len, offset; bool bOldMouseVisibility; int nOldMouseX, nOldMouseY; strcpy(t, text); lines = DlgAlert_FormatTextToBox(t, maxlen, &len); offset = (maxlen-len)/2; for(i=0; i #include #include #include #include #include "sdlgui.h" #include "file.h" #define PATHSEP '/' #define SGFS_NUMENTRIES 16 /* How many entries are displayed at once */ #define SGFSDLG_FILENAME 5 #define SGFSDLG_UPDIR 6 #define SGFSDLG_HOMEDIR 7 #define SGFSDLG_ROOTDIR 8 #define SGFSDLG_ENTRYFIRST 11 #define SGFSDLG_ENTRYLAST 26 #define SGFSDLG_SCROLLBAR 27 #define SGFSDLG_UP 28 #define SGFSDLG_DOWN 29 #define SGFSDLG_SHOWHIDDEN 30 #define SGFSDLG_OKAY 31 #define SGFSDLG_CANCEL 32 #define SCROLLOUT_ABOVE 1 #define SCROLLOUT_UNDER 2 #define DLGPATH_SIZE 62 static char dlgpath[DLGPATH_SIZE+1]; /* Path name in the dialog */ #define DLGFNAME_SIZE 56 static char dlgfname[DLGFNAME_SIZE+1]; /* Name of the selected file in the dialog */ #define DLGFILENAMES_SIZE 59 static char dlgfilenames[SGFS_NUMENTRIES][DLGFILENAMES_SIZE+1]; /* Visible file names in the dialog */ /* The dialog data: */ static SGOBJ fsdlg[] = { { SGBOX, 0, 0, 0,0, 64,24, NULL }, { SGTEXT, 0, 0, 25,1, 13,1, "Choose a file" }, { SGTEXT, 0, 0, 1,2, 7,1, "Folder:" }, { SGTEXT, 0, 0, 1,3, DLGPATH_SIZE,1, dlgpath }, { SGTEXT, 0, 0, 1,4, 6,1, "File:" }, { SGTEXT, 0, 0, 7,4, DLGFNAME_SIZE,1, dlgfname }, { SGBUTTON, 0, 0, 51,1, 4,1, ".." }, { SGBUTTON, 0, 0, 56,1, 3,1, "~" }, { SGBUTTON, 0, 0, 60,1, 3,1, "/" }, { SGBOX, 0, 0, 1,6, 62,16, NULL }, { SGBOX, 0, 0, 62,7, 1,14, NULL }, { SGTEXT, SG_EXIT, 0, 2,6, DLGFILENAMES_SIZE,1, dlgfilenames[0] }, { SGTEXT, SG_EXIT, 0, 2,7, DLGFILENAMES_SIZE,1, dlgfilenames[1] }, { SGTEXT, SG_EXIT, 0, 2,8, DLGFILENAMES_SIZE,1, dlgfilenames[2] }, { SGTEXT, SG_EXIT, 0, 2,9, DLGFILENAMES_SIZE,1, dlgfilenames[3] }, { SGTEXT, SG_EXIT, 0, 2,10, DLGFILENAMES_SIZE,1, dlgfilenames[4] }, { SGTEXT, SG_EXIT, 0, 2,11, DLGFILENAMES_SIZE,1, dlgfilenames[5] }, { SGTEXT, SG_EXIT, 0, 2,12, DLGFILENAMES_SIZE,1, dlgfilenames[6] }, { SGTEXT, SG_EXIT, 0, 2,13, DLGFILENAMES_SIZE,1, dlgfilenames[7] }, { SGTEXT, SG_EXIT, 0, 2,14, DLGFILENAMES_SIZE,1, dlgfilenames[8] }, { SGTEXT, SG_EXIT, 0, 2,15, DLGFILENAMES_SIZE,1, dlgfilenames[9] }, { SGTEXT, SG_EXIT, 0, 2,16, DLGFILENAMES_SIZE,1, dlgfilenames[10] }, { SGTEXT, SG_EXIT, 0, 2,17, DLGFILENAMES_SIZE,1, dlgfilenames[11] }, { SGTEXT, SG_EXIT, 0, 2,18, DLGFILENAMES_SIZE,1, dlgfilenames[12] }, { SGTEXT, SG_EXIT, 0, 2,19, DLGFILENAMES_SIZE,1, dlgfilenames[13] }, { SGTEXT, SG_EXIT, 0, 2,20, DLGFILENAMES_SIZE,1, dlgfilenames[14] }, { SGTEXT, SG_EXIT, 0, 2,21, DLGFILENAMES_SIZE,1, dlgfilenames[15] }, { SGSCROLLBAR, SG_TOUCHEXIT, 0, 62, 7, 0, 0, NULL }, /* Scrollbar */ { SGBUTTON, SG_TOUCHEXIT, 0, 62, 6,1,1, "\x01" }, /* Arrow up */ { SGBUTTON, SG_TOUCHEXIT, 0, 62,21,1,1, "\x02" }, /* Arrow down */ { SGCHECKBOX, SG_EXIT, 0, 2,23, 18,1, "Show hidden files" }, { SGBUTTON, SG_DEFAULT, 0, 32,23, 8,1, "Okay" }, { SGBUTTON, SG_CANCEL, 0, 50,23, 8,1, "Cancel" }, { -1, 0, 0, 0,0, 0,0, NULL } }; static int ypos; /* First entry number to be displayed */ static bool refreshentries; /* Do we have to update the file names in the dialog? */ static int entries; /* How many files are in the actual directory? */ static int oldMouseY = 0; /* Keep the latest Y mouse position for scrollbar move computing */ static int mouseClicked = 0; /* used to know if mouse if down for the first time or not */ static int mouseIsOut = 0; /* used to keep info that mouse if above or under the scrollbar when mousebutton is down */ static float scrollbar_Ypos = 0.0; /* scrollbar heigth */ /* Convert file position (in file list) to scrollbar y position */ static void DlgFileSelect_Convert_ypos_to_scrollbar_Ypos(void); /*-----------------------------------------------------------------------*/ /** * Update the file name strings in the dialog. * Returns false if it failed, true on success. */ static int DlgFileSelect_RefreshEntries(struct dirent **files, char *path, bool browsingzip) { int i; char *tempstr = malloc(FILENAME_MAX); if (!tempstr) { perror("DlgFileSelect_RefreshEntries"); return false; } /* Copy entries to dialog: */ for (i=0; id_name); File_ShrinkName(dlgfilenames[i], tempstr, DLGFILENAMES_SIZE); /* Mark folders: */ strcpy(tempstr, path); strcat(tempstr, files[i+ypos]->d_name); if (browsingzip) { if (File_DoesFileNameEndWithSlash(tempstr)) dlgfilenames[i][0] = SGFOLDER; /* Mark folders */ } else { if( stat(tempstr, &filestat)==0 && S_ISDIR(filestat.st_mode) ) dlgfilenames[i][0] = SGFOLDER; /* Mark folders */ #ifdef WITH_ZIP if (ZIP_FileNameIsZIP(tempstr) && browsingzip == false) dlgfilenames[i][0] = SGFOLDER; /* Mark .ZIP archives as folders */ #endif } } else dlgfilenames[i][0] = 0; /* Clear entry */ } free(tempstr); return true; } /*-----------------------------------------------------------------------*/ /** * Remove all hidden files (files with file names that begin with a dot) from * the list. */ static void DlgFileSelect_RemoveHiddenFiles(struct dirent **files) { int i; int nActPos = -1; int nOldEntries; nOldEntries = entries; /* Scan list for hidden files and remove them. */ for (i = 0; i < nOldEntries; i++) { /* Does file name start with a dot? -> hidden file! */ if (files[i]->d_name[0] == '.') { if (nActPos == -1) nActPos = i; /* Remove file from list: */ free(files[i]); files[i] = NULL; entries -= 1; } } /* Now close the gaps in the list: */ if (nActPos != -1) { for (i = nActPos; i < nOldEntries; i++) { if (files[i] != NULL) { /* Move entry to earlier position: */ files[nActPos] = files[i]; files[i] = NULL; nActPos += 1; } } } } /*-----------------------------------------------------------------------*/ /** * Prepare to scroll up one entry. */ static void DlgFileSelect_ScrollUp(void) { if (ypos > 0) { --ypos; DlgFileSelect_Convert_ypos_to_scrollbar_Ypos(); refreshentries = true; } } /*-----------------------------------------------------------------------*/ /** * Prepare to scroll down one entry. */ static void DlgFileSelect_ScrollDown(void) { if (ypos+SGFS_NUMENTRIES < entries) { ++ypos; DlgFileSelect_Convert_ypos_to_scrollbar_Ypos(); refreshentries = true; } } /*-----------------------------------------------------------------------*/ /** * Manage the scrollbar up or down. */ static void DlgFileSelect_ManageScrollbar(void) { int b, x, y; int scrollY, scrollYmin, scrollYmax, scrollH_half; float scrollMove; b = SDL_GetMouseState(&x, &y); /* If mouse is down on the scrollbar for the first time */ if (fsdlg[SGFSDLG_SCROLLBAR].state & SG_MOUSEDOWN) { if (mouseClicked == 0) { mouseClicked = 1; mouseIsOut = 0; oldMouseY = y; } } /* Mouse button is up on the scrollbar */ else { mouseClicked = 0; oldMouseY = y; mouseIsOut = 0; } /* If mouse Y position didn't change */ if (oldMouseY == y) return; /* Compute scrollbar ymin and ymax values */ scrollYmin = (fsdlg[SGFSDLG_SCROLLBAR].y + fsdlg[0].y) * sdlgui_fontheight; scrollYmax = (fsdlg[SGFSDLG_DOWN].y + fsdlg[0].y) * sdlgui_fontheight; scrollY = fsdlg[SGFSDLG_SCROLLBAR].y * sdlgui_fontheight + fsdlg[SGFSDLG_SCROLLBAR].h + fsdlg[0].y * sdlgui_fontheight; scrollH_half = scrollY + fsdlg[SGFSDLG_SCROLLBAR].w / 2; scrollMove = (float)(y-oldMouseY)/sdlgui_fontheight; /* Verify if mouse is not above the scrollbar area */ if (y < scrollYmin) { mouseIsOut = SCROLLOUT_ABOVE; oldMouseY = y; return; } if (mouseIsOut == SCROLLOUT_ABOVE && y < scrollH_half) { oldMouseY = y; return; } /* Verify if mouse is not under the scrollbar area */ if (y > scrollYmax) { mouseIsOut = SCROLLOUT_UNDER; oldMouseY = y; return; } if (mouseIsOut == SCROLLOUT_UNDER && y > scrollH_half) { oldMouseY = y; return; } mouseIsOut = 0; scrollbar_Ypos += scrollMove; oldMouseY = y; /* Verifiy if scrollbar is in correct inferior boundary */ if (scrollbar_Ypos < 0) scrollbar_Ypos = 0.0; /* Verifiy if scrollbar is in correct superior boundary */ b = (int) (scrollbar_Ypos * ((float)entries/(float)(SGFS_NUMENTRIES-2)) + 0.5); if (b+SGFS_NUMENTRIES >= entries) { ypos = entries - SGFS_NUMENTRIES; DlgFileSelect_Convert_ypos_to_scrollbar_Ypos(); } refreshentries = true; } /*-----------------------------------------------------------------------*/ /** * Handle SDL events. */ static void DlgFileSelect_HandleSdlEvents(SDL_Event *pEvent) { int oldypos = ypos; switch (pEvent->type) { case SDL_MOUSEBUTTONDOWN: if (pEvent->button.button == SDL_BUTTON_WHEELUP) DlgFileSelect_ScrollUp(); else if (pEvent->button.button == SDL_BUTTON_WHEELDOWN) DlgFileSelect_ScrollDown(); break; case SDL_KEYDOWN: switch (pEvent->key.keysym.sym) { case SDLK_UP: DlgFileSelect_ScrollUp(); break; case SDLK_DOWN: DlgFileSelect_ScrollDown(); break; case SDLK_HOME: ypos = 0; DlgFileSelect_Convert_ypos_to_scrollbar_Ypos(); break; case SDLK_END: ypos = entries-SGFS_NUMENTRIES; DlgFileSelect_Convert_ypos_to_scrollbar_Ypos(); break; case SDLK_PAGEUP: ypos -= SGFS_NUMENTRIES; DlgFileSelect_Convert_ypos_to_scrollbar_Ypos(); break; case SDLK_PAGEDOWN: if (ypos+2*SGFS_NUMENTRIES < entries) ypos += SGFS_NUMENTRIES; else ypos = entries-SGFS_NUMENTRIES; DlgFileSelect_Convert_ypos_to_scrollbar_Ypos(); break; default: break; } break; default: break; } if (ypos < 0) { ypos = 0; scrollbar_Ypos = 0.0; } if (ypos != oldypos) refreshentries = true; } /*-----------------------------------------------------------------------*/ /** * Free file entries */ static struct dirent **files_free(struct dirent **files) { int i; if (files != NULL) { for(i=0; i