Skip to content

Commit

Permalink
#1247: removed file dialogs, added ArgParse lib to parse app argument…
Browse files Browse the repository at this point in the history
…s, temporary removed code/sprites/map injection
  • Loading branch information
nesbox committed Nov 16, 2020
1 parent 31d56a3 commit 1597f7b
Show file tree
Hide file tree
Showing 31 changed files with 160 additions and 2,272 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@
url = https://github.com/kuba--/zip.git
[submodule "vendor/moonscript"]
path = vendor/moonscript
url = https://github.com/nesbox/moonscript.git
url = https://github.com/nesbox/moonscript.git
[submodule "vendor/argparse"]
path = vendor/argparse
url = https://github.com/cofyc/argparse.git
43 changes: 5 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,6 @@ if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID AND NOT N3DS)
set(LINUX TRUE)
endif()

if(LINUX)
include(FindPkgConfig)
if(NOT PKG_CONFIG_FOUND)
message(WARNING "We need pkg-config to detect GTK libs")
else()
pkg_check_modules(GTK gtk+-3.0)
endif()
endif()

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
Expand Down Expand Up @@ -654,31 +645,11 @@ add_library(wave_writer STATIC ${THIRDPARTY_DIR}/blip-buf/wave_writer.c)
target_include_directories(wave_writer INTERFACE ${THIRDPARTY_DIR}/blip-buf)

################################
# File dialogs
# ArgParse lib
################################

add_library(file_dialogs STATIC ${CMAKE_SOURCE_DIR}/src/ext/file_dialog.c)
target_include_directories(file_dialogs PRIVATE ${CMAKE_SOURCE_DIR}/include)

if(LINUX)
if(${GTK_FOUND})
target_include_directories(file_dialogs PRIVATE ${GTK_INCLUDE_DIRS})
target_link_libraries(file_dialogs ${GTK_LIBRARIES})
set(FILE_DIALOGS_SUPPORT ON)
endif()
else()
set(FILE_DIALOGS_SUPPORT ON)

if(APPLE)
target_sources(file_dialogs PRIVATE ${CMAKE_SOURCE_DIR}/src/ext/file_dialog.m)
elseif(ANDROID)
target_include_directories(file_dialogs PRIVATE ${THIRDPARTY_DIR}/sdl2/include)
endif()
endif()

if(FILE_DIALOGS_SUPPORT)
target_compile_definitions(file_dialogs PUBLIC FILE_DIALOGS_SUPPORT)
endif()
add_library(argparse STATIC ${THIRDPARTY_DIR}/argparse/argparse.c)
target_include_directories(argparse INTERFACE ${THIRDPARTY_DIR}/argparse)

################################
# TIC-80 studio
Expand Down Expand Up @@ -718,11 +689,7 @@ endif()

target_include_directories(tic80studio PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

target_link_libraries(tic80studio tic80core zip wave_writer)

if(FILE_DIALOGS_SUPPORT)
target_link_libraries(tic80studio file_dialogs)
endif()
target_link_libraries(tic80studio tic80core zip wave_writer argparse)

if(N3DS)
target_include_directories(tic80studio PRIVATE ${DEVKITPRO}/portlibs/3ds/include)
Expand Down Expand Up @@ -861,7 +828,7 @@ if(BUILD_SDL)
endif()

if(EMSCRIPTEN)
set_target_properties(tic80 PROPERTIES LINK_FLAGS "-s WASM=1 -s USE_SDL=2 -s TOTAL_MEMORY=67108864 --pre-js ${CMAKE_SOURCE_DIR}/build/html/prejs.js -lidbfs.js")
set_target_properties(tic80 PROPERTIES LINK_FLAGS "-s WASM=1 -s USE_SDL=2 -s TOTAL_MEMORY=67108864 -lidbfs.js")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_SDL=2")

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
Expand Down
114 changes: 1 addition & 113 deletions build/android/app/src/main/java/com/nesbox/tic/TIC.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package com.nesbox.tic;

import com.samsung.sprc.fileselector.FileSelector;
import com.samsung.sprc.fileselector.FileOperation;
import com.samsung.sprc.fileselector.OnHandleFileListener;

import org.libsdl.app.SDLActivity;

public class TIC extends SDLActivity
Expand All @@ -15,112 +11,4 @@ protected String[] getLibraries() {
"tic80",
};
}

protected final String[] fileSelectorResult = new String[]{""};

public String saveFile(final String name)
{
fileSelectorResult[0] = "";

runOnUiThread(new Runnable()
{
@Override
public void run()
{
new FileSelector(TIC.this, FileOperation.SAVE, mSaveFileListener, name).show();
}
});

synchronized (fileSelectorResult)
{
try
{
fileSelectorResult.wait();
}
catch (InterruptedException ex)
{
ex.printStackTrace();
}
}

return fileSelectorResult[0];
}

OnHandleFileListener mSaveFileListener = new OnHandleFileListener()
{
@Override
public void handleFile(final String filePath)
{
fileSelectorResult[0] = filePath;

synchronized (fileSelectorResult)
{
fileSelectorResult.notify();
}
}

@Override
public void handleCancel()
{
fileSelectorResult[0] = "";

synchronized (fileSelectorResult)
{
fileSelectorResult.notify();
}
}
};

public String loadFile()
{
fileSelectorResult[0] = "";

runOnUiThread(new Runnable()
{
@Override
public void run()
{
new FileSelector(TIC.this, FileOperation.LOAD, mLoadFileListener, "").show();
}
});

synchronized (fileSelectorResult)
{
try
{
fileSelectorResult.wait();
}
catch (InterruptedException ex)
{
ex.printStackTrace();
}
}

return fileSelectorResult[0];
}

OnHandleFileListener mLoadFileListener = new OnHandleFileListener()
{
@Override
public void handleFile(final String filePath)
{
fileSelectorResult[0] = filePath;

synchronized (fileSelectorResult)
{
fileSelectorResult.notify();
}
}

@Override
public void handleCancel()
{
fileSelectorResult[0] = "";

synchronized (fileSelectorResult)
{
fileSelectorResult.notify();
}
}
};
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1597f7b

Please sign in to comment.