Populate additional Config values, use company name and file name for preference path
This commit is contained in:
@@ -4,20 +4,26 @@ package lime.app;
|
||||
typedef Config = {
|
||||
|
||||
@:optional var antialiasing:Int;
|
||||
#if (js && html5)
|
||||
@:optional var assetsPrefix:String;
|
||||
#end
|
||||
@:optional var background:Null<Int>;
|
||||
@:optional var borderless:Bool;
|
||||
@:optional var company:String;
|
||||
@:optional var depthBuffer:Bool;
|
||||
#if (js && html5)
|
||||
@:optional var element:#if (haxe_ver >= "3.2") js.html.Element #else js.html.HtmlElement #end;
|
||||
@:optional var assetsPrefix:String;
|
||||
#end
|
||||
@:optional var file:String;
|
||||
@:optional var fps:Int;
|
||||
@:optional var fullscreen:Bool;
|
||||
@:optional var height:Int;
|
||||
@:optional var orientation:String;
|
||||
@:optional var packageName:String;
|
||||
@:optional var resizable:Bool;
|
||||
@:optional var stencilBuffer:Bool;
|
||||
@:optional var title:String;
|
||||
@:optional var version:String;
|
||||
@:optional var vsync:Bool;
|
||||
@:optional var width:Int;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package lime.system;
|
||||
import lime.app.Application;
|
||||
|
||||
|
||||
#if flash
|
||||
@@ -409,7 +410,7 @@ class System {
|
||||
private static function get_applicationDirectory ():String {
|
||||
|
||||
#if (cpp || neko || nodejs)
|
||||
return lime_system_get_directory (SystemDirectory.APPLICATION);
|
||||
return lime_system_get_directory (SystemDirectory.APPLICATION, null, null);
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
@@ -419,8 +420,27 @@ class System {
|
||||
|
||||
private static function get_applicationStorageDirectory ():String {
|
||||
|
||||
var company = "MyCompany";
|
||||
var file = "MyApplication";
|
||||
|
||||
if (Application.current != null && Application.current.config != null) {
|
||||
|
||||
if (Application.current.config.company != null) {
|
||||
|
||||
company = Application.current.config.company;
|
||||
|
||||
}
|
||||
|
||||
if (Application.current.config.file != null) {
|
||||
|
||||
file = Application.current.config.file;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if (cpp || neko || nodejs)
|
||||
return lime_system_get_directory (SystemDirectory.APPLICATION_STORAGE);
|
||||
return lime_system_get_directory (SystemDirectory.APPLICATION_STORAGE, company, file);
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
@@ -431,7 +451,7 @@ class System {
|
||||
private static function get_desktopDirectory ():String {
|
||||
|
||||
#if (cpp || neko || nodejs)
|
||||
return lime_system_get_directory (SystemDirectory.DESKTOP);
|
||||
return lime_system_get_directory (SystemDirectory.DESKTOP, null, null);
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
@@ -442,7 +462,7 @@ class System {
|
||||
private static function get_documentsDirectory ():String {
|
||||
|
||||
#if (cpp || neko || nodejs)
|
||||
return lime_system_get_directory (SystemDirectory.DOCUMENTS);
|
||||
return lime_system_get_directory (SystemDirectory.DOCUMENTS, null, null);
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
@@ -453,7 +473,7 @@ class System {
|
||||
private static function get_userDirectory ():String {
|
||||
|
||||
#if (cpp || neko || nodejs)
|
||||
return lime_system_get_directory (SystemDirectory.USER);
|
||||
return lime_system_get_directory (SystemDirectory.USER, null, null);
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
@@ -469,7 +489,7 @@ class System {
|
||||
|
||||
|
||||
#if (cpp || neko || nodejs)
|
||||
private static var lime_system_get_directory = System.load ("lime", "lime_system_get_directory", 1);
|
||||
private static var lime_system_get_directory = System.load ("lime", "lime_system_get_directory", 3);
|
||||
private static var lime_system_get_timer = System.load ("lime", "lime_system_get_timer", 0);
|
||||
#end
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace lime {
|
||||
|
||||
public:
|
||||
|
||||
static const char* GetDirectory (SystemDirectory type);
|
||||
static const char* GetDirectory (SystemDirectory type, const char* company, const char* title);
|
||||
static double GetTimer ();
|
||||
|
||||
|
||||
|
||||
@@ -559,9 +559,15 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_system_get_directory (value type) {
|
||||
value lime_system_get_directory (value type, value company, value title) {
|
||||
|
||||
return alloc_string (System::GetDirectory ((SystemDirectory)val_int (type)));
|
||||
const char* companyName = "";
|
||||
const char* titleName = "";
|
||||
|
||||
if (!val_is_null (company)) companyName = val_string (company);
|
||||
if (!val_is_null (title)) titleName = val_string (title);
|
||||
|
||||
return alloc_string (System::GetDirectory ((SystemDirectory)val_int (type), companyName, titleName));
|
||||
|
||||
}
|
||||
|
||||
@@ -764,7 +770,7 @@ namespace lime {
|
||||
DEFINE_PRIM (lime_renderer_create, 1);
|
||||
DEFINE_PRIM (lime_renderer_flip, 1);
|
||||
DEFINE_PRIM (lime_render_event_manager_register, 2);
|
||||
DEFINE_PRIM (lime_system_get_directory, 1);
|
||||
DEFINE_PRIM (lime_system_get_directory, 3);
|
||||
DEFINE_PRIM (lime_system_get_timer, 0);
|
||||
DEFINE_PRIM (lime_text_layout_create, 3);
|
||||
DEFINE_PRIM (lime_text_layout_position, 5);
|
||||
|
||||
@@ -28,20 +28,18 @@
|
||||
namespace lime {
|
||||
|
||||
|
||||
const char* System::GetDirectory (SystemDirectory type) {
|
||||
const char* System::GetDirectory (SystemDirectory type, const char* company, const char* title) {
|
||||
|
||||
switch (type) {
|
||||
|
||||
case APPLICATION:
|
||||
|
||||
// TODO: Need to get the user's company and title or package name
|
||||
// previous behavior was the company + file
|
||||
return SDL_GetPrefPath ("My Company", "My Awesome SDL 2 Game");
|
||||
return SDL_GetBasePath ();
|
||||
break;
|
||||
|
||||
case APPLICATION_STORAGE:
|
||||
|
||||
return SDL_GetBasePath ();
|
||||
return SDL_GetPrefPath (company, title);
|
||||
break;
|
||||
|
||||
case DESKTOP: {
|
||||
|
||||
@@ -64,14 +64,18 @@ class ApplicationMain {
|
||||
antialiasing: Std.int (::WIN_ANTIALIASING::),
|
||||
background: Std.int (::WIN_BACKGROUND::),
|
||||
borderless: ::WIN_BORDERLESS::,
|
||||
company: "::META_COMPANY::",
|
||||
depthBuffer: ::WIN_DEPTH_BUFFER::,
|
||||
file: "::APP_FILE::",
|
||||
fps: Std.int (::WIN_FPS::),
|
||||
fullscreen: ::WIN_FULLSCREEN::,
|
||||
height: Std.int (::WIN_HEIGHT::),
|
||||
orientation: "::WIN_ORIENTATION::",
|
||||
packageName: "::META_PACKAGE_NAME::",
|
||||
resizable: ::WIN_RESIZABLE::,
|
||||
stencilBuffer: ::WIN_STENCIL_BUFFER::,
|
||||
title: "::APP_TITLE::",
|
||||
version: "::META_VERSION::",
|
||||
vsync: ::WIN_VSYNC::,
|
||||
width: Std.int (::WIN_WIDTH::),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user