mirror of
https://github.com/autc04/Retro68.git
synced 2025-02-19 09:31:37 +00:00
Integrate Rez with the add_application cmake command, add "Dialog" sample
This commit is contained in:
parent
9ecd799562
commit
9237ce6392
@ -29,6 +29,7 @@ add_subdirectory(TestApps)
|
|||||||
add_subdirectory(Samples/HelloWorld)
|
add_subdirectory(Samples/HelloWorld)
|
||||||
add_subdirectory(Samples/Raytracer)
|
add_subdirectory(Samples/Raytracer)
|
||||||
add_subdirectory(Samples/Launcher)
|
add_subdirectory(Samples/Launcher)
|
||||||
|
add_subdirectory(Samples/Dialog)
|
||||||
else()
|
else()
|
||||||
|
|
||||||
configure_file(cmake/retro68.toolchain.cmake.in cmake/retro68.toolchain.cmake @ONLY)
|
configure_file(cmake/retro68.toolchain.cmake.in cmake/retro68.toolchain.cmake @ONLY)
|
||||||
|
@ -83,7 +83,7 @@ int main(int argc, const char *argv[])
|
|||||||
world.getResources().addResources(rsrcFile.resources);
|
world.getResources().addResources(rsrcFile.resources);
|
||||||
}
|
}
|
||||||
if(options.count("copy"))
|
if(options.count("copy"))
|
||||||
for(std::string copyFile : options["define"].as<std::vector<std::string>>())
|
for(std::string copyFile : options["copy"].as<std::vector<std::string>>())
|
||||||
{
|
{
|
||||||
ResourceFile copyRsrc(copyFile);
|
ResourceFile copyRsrc(copyFile);
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ static std::string preFilter(std::string str)
|
|||||||
boost::regex dollar_escape("\\\\\\$([a-zA-Z0-9][a-zA-Z0-9])");
|
boost::regex dollar_escape("\\\\\\$([a-zA-Z0-9][a-zA-Z0-9])");
|
||||||
str = boost::regex_replace(str, dollar_escape, "\\\\0x$1");
|
str = boost::regex_replace(str, dollar_escape, "\\\\0x$1");
|
||||||
|
|
||||||
|
if(str.size() == 0 || str[str.size()-1] != '\n')
|
||||||
|
str += "\n";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,5 +286,5 @@ case T_ ## name: /*std::cout << #name << std::endl;*/ return RezParser::make_ ##
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return RezSymbol();
|
return RezParser::symbol_type(RezParser::token_type(0), yy::location());
|
||||||
}
|
}
|
||||||
|
29
Samples/Dialog/CMakeLists.txt
Normal file
29
Samples/Dialog/CMakeLists.txt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# Copyright 2015 Wolfgang Thaller.
|
||||||
|
#
|
||||||
|
# This file is part of Retro68.
|
||||||
|
#
|
||||||
|
# Retro68 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 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Retro68 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 for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with Retro68. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# To use this example as a standalone project using CMake:
|
||||||
|
# mkdir build
|
||||||
|
# cd build
|
||||||
|
# cmake .. -DCMAKE_TOOLCHAIN_FILE=path/to/Retro68-build/toolchain/cmake/retro68.toolchain.cmake
|
||||||
|
# make
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
add_application(Dialog
|
||||||
|
dialog.c
|
||||||
|
dialog.r
|
||||||
|
)
|
84
Samples/Dialog/dialog.c
Normal file
84
Samples/Dialog/dialog.c
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2015 Wolfgang Thaller.
|
||||||
|
|
||||||
|
This file is part of Retro68.
|
||||||
|
|
||||||
|
Retro68 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 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Retro68 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 for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Retro68. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Quickdraw.h>
|
||||||
|
#include <Dialogs.h>
|
||||||
|
|
||||||
|
QDGlobals qd;
|
||||||
|
|
||||||
|
pascal void ButtonFrameProc(DialogRef dlg, DialogItemIndex itemNo)
|
||||||
|
{
|
||||||
|
DialogItemType type;
|
||||||
|
Handle itemH;
|
||||||
|
Rect box;
|
||||||
|
|
||||||
|
GetDialogItem(dlg, 1, &type, &itemH, &box);
|
||||||
|
InsetRect(&box, -4, -4);
|
||||||
|
PenSize(3,3);
|
||||||
|
FrameRoundRect(&box,16,16);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
WindowPtr win;
|
||||||
|
|
||||||
|
InitGraf(&qd.thePort);
|
||||||
|
InitFonts();
|
||||||
|
InitWindows();
|
||||||
|
InitMenus();
|
||||||
|
|
||||||
|
DialogPtr dlg = GetNewDialog(128,0,(WindowPtr)-1);
|
||||||
|
InitCursor();
|
||||||
|
SelectDialogItemText(dlg,4,0,32767);
|
||||||
|
|
||||||
|
DialogItemType type;
|
||||||
|
Handle itemH;
|
||||||
|
Rect box;
|
||||||
|
|
||||||
|
GetDialogItem(dlg, 2, &type, &itemH, &box);
|
||||||
|
SetDialogItem(dlg, 2, type, (Handle) NewUserItemUPP(&ButtonFrameProc), &box);
|
||||||
|
|
||||||
|
ControlHandle cb, radio1, radio2;
|
||||||
|
GetDialogItem(dlg, 5, &type, &itemH, &box);
|
||||||
|
cb = (ControlHandle)itemH;
|
||||||
|
GetDialogItem(dlg, 6, &type, &itemH, &box);
|
||||||
|
radio1 = (ControlHandle)itemH;
|
||||||
|
GetDialogItem(dlg, 7, &type, &itemH, &box);
|
||||||
|
radio2 = (ControlHandle)itemH;
|
||||||
|
SetControlValue(radio1, 1);
|
||||||
|
|
||||||
|
short item;
|
||||||
|
do {
|
||||||
|
ModalDialog(NULL, &item);
|
||||||
|
|
||||||
|
if(item >= 5 && item <= 7)
|
||||||
|
{
|
||||||
|
if(item == 5)
|
||||||
|
SetControlValue(cb, !GetControlValue(cb));
|
||||||
|
if(item == 6 || item == 7)
|
||||||
|
{
|
||||||
|
SetControlValue(radio1, item == 6);
|
||||||
|
SetControlValue(radio2, item == 7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while(item != 1);
|
||||||
|
|
||||||
|
FlushEvents(everyEvent, -1);
|
||||||
|
return 0;
|
||||||
|
}
|
56
Samples/Dialog/dialog.r
Normal file
56
Samples/Dialog/dialog.r
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2015 Wolfgang Thaller.
|
||||||
|
|
||||||
|
This file is part of Retro68.
|
||||||
|
|
||||||
|
Retro68 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 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Retro68 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 for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Retro68. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Dialogs.r"
|
||||||
|
|
||||||
|
resource 'DLOG' (128) {
|
||||||
|
{ 50, 100, 240, 420 },
|
||||||
|
dBoxProc,
|
||||||
|
visible,
|
||||||
|
noGoAway,
|
||||||
|
0,
|
||||||
|
128,
|
||||||
|
"",
|
||||||
|
centerMainScreen
|
||||||
|
};
|
||||||
|
|
||||||
|
resource 'DITL' (128) {
|
||||||
|
{
|
||||||
|
{ 190-10-20, 320-10-80, 190-10, 320-10 },
|
||||||
|
Button { enabled, "Quit" };
|
||||||
|
|
||||||
|
{ 190-10-20-5, 320-10-80-5, 190-10+5, 320-10+5 },
|
||||||
|
UserItem { enabled };
|
||||||
|
|
||||||
|
{ 10, 10, 30, 310 },
|
||||||
|
StaticText { enabled, "Static Text Item" };
|
||||||
|
|
||||||
|
{ 40, 10, 56, 310 },
|
||||||
|
EditText { enabled, "Edit Text Item" };
|
||||||
|
|
||||||
|
{ 70, 10, 86, 310 },
|
||||||
|
CheckBox { enabled, "Check Box" };
|
||||||
|
|
||||||
|
{ 90, 10, 106, 310 },
|
||||||
|
RadioButton { enabled, "Radio 1" };
|
||||||
|
|
||||||
|
{ 110, 10, 126, 310 },
|
||||||
|
RadioButton { enabled, "Radio 2" };
|
||||||
|
}
|
||||||
|
};
|
@ -61,6 +61,9 @@ cd ..
|
|||||||
|
|
||||||
sh "$SRC/prepare-headers.sh" "$SRC/CIncludes" toolchain/m68k-unknown-elf/include
|
sh "$SRC/prepare-headers.sh" "$SRC/CIncludes" toolchain/m68k-unknown-elf/include
|
||||||
|
|
||||||
|
mkdir -p toolchain/RIncludes
|
||||||
|
cp '$SRC/RIncludes/*.r' toolchain/RIncludes/
|
||||||
|
|
||||||
mkdir -p build-host
|
mkdir -p build-host
|
||||||
cd build-host
|
cd build-host
|
||||||
cmake ${SRC} -DCMAKE_INSTALL_PREFIX=$PREFIX
|
cmake ${SRC} -DCMAKE_INSTALL_PREFIX=$PREFIX
|
||||||
|
@ -13,8 +13,21 @@ function(add_application name)
|
|||||||
list(APPEND ARGS_FILES ${ARGS_UNPARSED_ARGUMENTS})
|
list(APPEND ARGS_FILES ${ARGS_UNPARSED_ARGUMENTS})
|
||||||
|
|
||||||
set(files)
|
set(files)
|
||||||
|
set(rsrc_files)
|
||||||
foreach(f ${ARGS_FILES})
|
foreach(f ${ARGS_FILES})
|
||||||
|
if(${f} MATCHES "\\.r$")
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${f}.rsrc
|
||||||
|
COMMAND ${REZ} ${CMAKE_CURRENT_SOURCE_DIR}/${f} -I ${REZ_INCLUDE_PATH} -o ${f}.rsrc
|
||||||
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${f})
|
||||||
|
list(APPEND rsrc_files "${CMAKE_CURRENT_BINARY_DIR}/${f}.rsrc")
|
||||||
|
elseif(${f} MATCHES "\\.rsrc$")
|
||||||
|
list(APPEND rsrc_files "${f}")
|
||||||
|
elseif(${f} MATCHES "\\.rsrc.bin$")
|
||||||
|
list(APPEND rsrc_files "${f}")
|
||||||
|
else()
|
||||||
list(APPEND files "${CMAKE_CURRENT_SOURCE_DIR}/${f}")
|
list(APPEND files "${CMAKE_CURRENT_SOURCE_DIR}/${f}")
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
add_executable(${name} ${files})
|
add_executable(${name} ${files})
|
||||||
@ -29,6 +42,11 @@ function(add_application name)
|
|||||||
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
|
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
foreach(f ${rsrc_files})
|
||||||
|
list(APPEND ARGS_MAKEAPPL_ARGS --copy "${f}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(TARGET libretro)
|
if(TARGET libretro)
|
||||||
set_target_properties(${name} PROPERTIES LINK_DEPENDS libretro)
|
set_target_properties(${name} PROPERTIES LINK_DEPENDS libretro)
|
||||||
@ -39,7 +57,7 @@ function(add_application name)
|
|||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${name}.bin ${name}.APPL ${name}.dsk
|
OUTPUT ${name}.bin ${name}.APPL ${name}.dsk
|
||||||
COMMAND ${MAKE_APPL} ${ARGS_MAKEAPPL_ARGS} -c "${name}.flt" -o "${name}"
|
COMMAND ${MAKE_APPL} ${ARGS_MAKEAPPL_ARGS} -c "${name}.flt" -o "${name}"
|
||||||
DEPENDS ${name})
|
DEPENDS ${name} ${rsrc_files})
|
||||||
add_custom_target(${name}_APPL ALL DEPENDS ${name}.bin)
|
add_custom_target(${name}_APPL ALL DEPENDS ${name}.bin)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ set( CMAKE_INSTALL_PREFIX "${RETRO68_ROOT}/m68k-unknown-elf/" CACHE PATH "instal
|
|||||||
|
|
||||||
set( MAKE_APPL "${RETRO68_ROOT}/bin/MakeAPPL" )
|
set( MAKE_APPL "${RETRO68_ROOT}/bin/MakeAPPL" )
|
||||||
set( REZ "${RETRO68_ROOT}/bin/Rez" )
|
set( REZ "${RETRO68_ROOT}/bin/Rez" )
|
||||||
|
set( REZ_INCLUDE_PATH "${RETRO68_ROOT}/RIncludes" )
|
||||||
|
|
||||||
set( CMAKE_C_COMPILER "${RETRO68_ROOT}/bin/m68k-unknown-elf-gcc" )
|
set( CMAKE_C_COMPILER "${RETRO68_ROOT}/bin/m68k-unknown-elf-gcc" )
|
||||||
set( CMAKE_CXX_COMPILER "${RETRO68_ROOT}/bin/m68k-unknown-elf-g++" )
|
set( CMAKE_CXX_COMPILER "${RETRO68_ROOT}/bin/m68k-unknown-elf-g++" )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user