Commit b415ce91 authored by David Bruce's avatar David Bruce

Merged Sarah's GSoC project (word list editor) into trunk

git-svn-id: svn://svn.debian.org/svn/tux4kids/tuxtype/trunk@1559 47d30e19-490b-0410-9d18-e851f4e465b3
parent 70aab5d2
......@@ -74,7 +74,8 @@ tuxtype_SOURCES = \
pause.c \
convert_utf.c \
options.c \
mysetenv.c
mysetenv.c \
editor.c
TuxType_SOURCES = $(tuxtype_SOURCES)
# The rc file has something to do with the icon in Windows, IIRC
......@@ -92,6 +93,5 @@ EXTRA_DIST = titlescreen.h \
convert_utf.h \
gettext.h \
compiler.h \
mysetenv.h
mysetenv.h \
editor.h
This diff is collapsed.
//
// C Interface: editor.h
//
// Description: Header for word- and phrase list-editing functionality for
// Tux Typing
//
// Author: Sarah Frisk <ssfrisk@gmail.com> and David Bruce <davidstuartbruce@gmail.com>, (C) 2009
//
// Written for Google Summer of Code 2009
//
// Copyright: See COPYING file that comes with this distribution (briefly, GNU GPLv2+)
//
//
#ifndef EDITOR_H
#define EDITOR_H
void ChooseListToEdit(void);
void EditWordList(char* words_file);
int CreateNewWordList(void);
int ChooseRemoveList(char *name, char *filename);
int RemoveList(char* words_file);
#define New 0
#define Remove 1
#define Done 2
#endif
......@@ -146,6 +146,7 @@ typedef struct game_option_type{
/* that can be present within a word list: */
#define MAX_NUM_WORDS 500
#define MAX_WORD_SIZE 20
#define MAX_WORD_LISTS 100
#define MAX_UNICODES 1024
#define WAIT_MS 2500
......
......@@ -22,6 +22,7 @@
#include "titlescreen.h"
#include "SDL_extras.h"
#include "convert_utf.h"
#include "editor.h"
/* --- media for menus --- */
......@@ -484,8 +485,10 @@ void TitleScreen(void)
if (menu_opt == EDIT_WORDLIST)
{
not_implemented();
// not_implemented();
// ChooseFile();
ChooseListToEdit();
redraw = 1;
}
......@@ -1281,6 +1284,66 @@ static int chooseWordlist(void)
closedir(wordsDir);
/* Adding custom wordlists */
sprintf(wordPath,"%s", settings.var_data_path);
if (!CheckFile(wordPath))
{
fprintf(stderr, "chooseWordList() - data path contains no wordlist dir \n");
return 0;
}
/* If we get to here, we know there is at least a wordlist directory */
/* but not necessarily any valid files. */
DEBUGCODE { fprintf(stderr, "wordPath is: %s\n", wordPath); }
/* FIXME looks like a place for scandir() - or our own w32_scandir() */
/* create a list of all the .txt files */
wordsDir = opendir( wordPath );
do
{
wordsFile = readdir(wordsDir);
if (!wordsFile)
break; /* Loop continues until break occurs */
/* must have at least .txt at the end */
if (strlen(wordsFile->d_name) < 5)
continue;
if (strcmp(&wordsFile->d_name[strlen(wordsFile->d_name) -4 ],".txt"))
continue;
sprintf(wordlistFile[lists], "%s/%s", wordPath, wordsFile->d_name);
/* load the name for the wordlist from the file ... (1st line) */
tempFile = fopen( wordlistFile[lists], "r" );
if (!tempFile)
continue;
result = fscanf(tempFile, "%[^\n]\n", wordlistName[lists]);
if (result == EOF)
continue;
/* check to see if it has a \r at the end of it (dos format!) */
if (wordlistName[lists][strlen(wordlistName[lists]) - 1] == '\r')
wordlistName[lists][strlen(wordlistName[lists]) - 1] = '\0';
lists++;
fclose(tempFile);
} while (1); /* Loop continues until break occurs */
closedir(wordsDir);
DEBUGCODE { fprintf(stderr, "Found %d .txt file(s) in words dir\n", lists); }
......@@ -1493,6 +1556,7 @@ static int chooseWordlist(void)
}
static void ChooseFile(void)
{
SDL_Surface* titles[MAX_WORD_LISTS] = {NULL};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment