mirror of
https://github.com/Alcaro/Flips.git
synced 2026-04-24 14:59:29 -05:00
Start shoving all this config to something platform-independent.
This commit is contained in:
parent
711da4f292
commit
289971ad78
|
|
@ -12,7 +12,9 @@ Planned:
|
|||
- Automatically enable ROM guesser (open a message box the first time it guesses a ROM, asking if you want that)
|
||||
- Different emulators for different filetypes (check the extension)
|
||||
- Better support for ROM database in CLI; the -d flag, or DB enabling from the GUI (for pure-CLI, existence of flipsdb.bin file beside Flips), will store ROMs in the database; the filename "-" will read from it, and "wrong ROM" will look for the right one (but not automatically use it)
|
||||
- Use path of patch as output filename, not the ROM path
|
||||
- Better autodetection for command line; if the first two files have same extension, create, else apply
|
||||
|
||||
Not planned (if your plans are different, send a PR):
|
||||
- Non-console OSX support; I don't have the right hardware
|
||||
- Qt support; my distro uses GNOME, and all distros I've seen can run both GTK+ and Qt (and QString's UTF16 irritates me)
|
||||
- Qt support; my distro uses GNOME, and all distros I've seen can run both GTK+ and Qt (and QString's UTF-16 irritates me)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
//Module name: Floating IPS, GTK+ frontend
|
||||
//Author: Alcaro
|
||||
//Date: June 18, 2015
|
||||
//Date: See Git timestamps
|
||||
//Licence: GPL v3.0 or higher
|
||||
|
||||
//List of assumptions made whose correctness is not guaranteed by GTK+:
|
||||
//The character '9' is as wide as the widest of '0' '1' '2' '3' '4' '5' '6' '7' '8' '9'.
|
||||
// Failure leads to: The BPS delta creation progress window being a little too small.
|
||||
// Fixable: Not hard, but unlikely to be worth it.
|
||||
|
||||
#include "flips.h"
|
||||
|
||||
#ifdef FLIPS_GTK
|
||||
|
|
@ -79,73 +80,6 @@ public:
|
|||
|
||||
filewrite* filewrite::create(const char * filename) { return filewrite_gtk::create(filename); }
|
||||
|
||||
//struct mem ReadWholeFile(const char * filename)
|
||||
//{
|
||||
// GFile* file=g_file_new_for_commandline_arg(filename);
|
||||
// if (!file) return (struct mem){NULL, 0};
|
||||
// GFileInputStream* io=g_file_read(file, NULL, NULL);
|
||||
// if (!io)
|
||||
// {
|
||||
// g_object_unref(file);
|
||||
// return (struct mem){NULL, 0};
|
||||
// }
|
||||
// GFileInfo* info=g_file_input_stream_query_info(io, G_FILE_ATTRIBUTE_STANDARD_SIZE, NULL, NULL);
|
||||
// gsize size=g_file_info_get_size(info);
|
||||
// struct mem mem={(uint8_t*)malloc(size), size};
|
||||
// gsize actualsize;
|
||||
// bool success=g_input_stream_read_all(G_INPUT_STREAM(io), mem.ptr, size, &actualsize, NULL, NULL);
|
||||
// if (size!=actualsize) success=false;
|
||||
// g_input_stream_close(G_INPUT_STREAM(io), NULL, NULL);
|
||||
// g_object_unref(file);
|
||||
// g_object_unref(io);
|
||||
// g_object_unref(info);
|
||||
// if (!success)
|
||||
// {
|
||||
// free(mem.ptr);
|
||||
// return (struct mem){NULL, 0};
|
||||
// }
|
||||
// return mem;
|
||||
//}
|
||||
//
|
||||
//bool WriteWholeFile(const char * filename, struct mem data)
|
||||
//{
|
||||
// GFile* file=g_file_new_for_commandline_arg(filename);
|
||||
// if (!file) return false;
|
||||
// GFileOutputStream* io=g_file_replace(file, NULL, false, G_FILE_CREATE_NONE, NULL, NULL);
|
||||
// if (!io)
|
||||
// {
|
||||
// g_object_unref(file);
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// bool success=g_output_stream_write_all(G_OUTPUT_STREAM(io), data.ptr, data.len, NULL, NULL, NULL);
|
||||
// g_output_stream_close(G_OUTPUT_STREAM(io), NULL, NULL);
|
||||
// g_object_unref(file);
|
||||
// return success;
|
||||
//}
|
||||
//
|
||||
//bool WriteWholeFileWithHeader(const char * filename, struct mem header, struct mem data)
|
||||
//{
|
||||
// GFile* file=g_file_new_for_commandline_arg(filename);
|
||||
// if (!file) return false;
|
||||
// GFileOutputStream* io=g_file_replace(file, NULL, false, G_FILE_CREATE_NONE, NULL, NULL);
|
||||
// if (!io)
|
||||
// {
|
||||
// g_object_unref(file);
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// bool success=(g_output_stream_write_all(G_OUTPUT_STREAM(io), header.ptr, 512, NULL, NULL, NULL) &&
|
||||
// g_output_stream_write_all(G_OUTPUT_STREAM(io), data.ptr, data.len, NULL, NULL, NULL));
|
||||
// g_output_stream_close(G_OUTPUT_STREAM(io), NULL, NULL);
|
||||
// g_object_unref(file);
|
||||
// return success;
|
||||
//}
|
||||
//
|
||||
//void FreeFileMemory(struct mem mem)
|
||||
//{
|
||||
// free(mem.ptr);
|
||||
//}
|
||||
|
||||
|
||||
static bool canShowGUI;
|
||||
|
|
|
|||
40
flips.cpp
40
flips.cpp
|
|
@ -176,6 +176,42 @@ enum patchtype IdentifyPatch(file* patch)
|
|||
return ty_null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
config::config(struct mem contents)
|
||||
{
|
||||
}
|
||||
|
||||
config::config(LPCWSTR filename)
|
||||
{
|
||||
}
|
||||
|
||||
void config::setbin(const char * name, struct mem value)
|
||||
{
|
||||
}
|
||||
|
||||
struct mem config::getbin(const char * name)
|
||||
{
|
||||
}
|
||||
|
||||
struct mem config::flatten()
|
||||
{
|
||||
}
|
||||
|
||||
config::~config()
|
||||
{
|
||||
if (this->filename) filewrite::write(this->filename, this->contents);
|
||||
free(this->filename);
|
||||
free(this->contents.ptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enum {
|
||||
ch_crc32,
|
||||
ch_last
|
||||
|
|
@ -349,6 +385,10 @@ void DeleteRomFromList(LPCWSTR path)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static struct errorinfo error(errorlevel level, const char * text)
|
||||
{
|
||||
struct errorinfo errinf = { level, text };
|
||||
|
|
|
|||
33
flips.h
33
flips.h
|
|
@ -66,11 +66,11 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
//Flips uses Windows types internally, since it's easier to #define them to Linux types than
|
||||
//Flips uses Windows type names internally, since it's easier to #define them to Linux types than
|
||||
//defining "const char *" to anything else, and since I use char* at some places (mainly libips/etc)
|
||||
//and really don't want to try to split them. Inventing my own typedefs seems counterproductive as
|
||||
//well; they would bring no advantage over Windows types except not being Windows types, and I don't
|
||||
//see that as a valid argument.
|
||||
//well; they would bring no advantage over Windows typenames except not being Windows typenames, and
|
||||
//I don't see that as a valid argument.
|
||||
#define LPCWSTR const char *
|
||||
#define LPWSTR char *
|
||||
#define WCHAR char
|
||||
|
|
@ -154,6 +154,33 @@ LPWSTR GetExtension(LPCWSTR fname);
|
|||
LPWSTR GetBaseName(LPCWSTR fname);
|
||||
bool shouldRemoveHeader(LPCWSTR romname, size_t romlen);
|
||||
|
||||
class config
|
||||
{
|
||||
LPWSTR filename;
|
||||
struct mem contents;
|
||||
|
||||
public:
|
||||
config(struct mem contents);
|
||||
config(LPCWSTR filename);
|
||||
|
||||
void set(const char * name, LPCWSTR value)
|
||||
{
|
||||
setbin(name, (struct mem){(uint8_t*)value, (wcslen(value)+1)*sizeof(WCHAR)});
|
||||
}
|
||||
void setbin(const char * name, struct mem value);
|
||||
|
||||
// free() these three when you're done with them.
|
||||
LPWSTR get(const char * name)
|
||||
{
|
||||
return (LPWSTR)(getbin(name).ptr);
|
||||
}
|
||||
struct mem getbin(const char * name);
|
||||
|
||||
struct mem flatten();
|
||||
|
||||
~config();
|
||||
};
|
||||
|
||||
struct mem GetRomList();
|
||||
void SetRomList(struct mem data);
|
||||
LPCWSTR FindRomForPatch(file* patch, bool * possibleToFind);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user