Skip to content

Commit b1a82e8

Browse files
authored
Merge pull request #137 (v0.1.1) from bazzinotti/finetune
v0.1.1
2 parents 519022a + 7b8c6aa commit b1a82e8

89 files changed

Lines changed: 5466 additions & 1919 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pc/Info.plist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<?xml version="1.0" encoding="UTF-8"?>
32
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
43
<plist version="1.0">
@@ -16,5 +15,7 @@
1615
</array>
1716
</dict>
1817
</array>
18+
<key>CFBundleIconFile</key>
19+
<string>st.icns</string>
1920
</dict>
2021
</plist>

pc/Makefile

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ endif
1818
global_requirements = $(LIBJDKMIDI_LIB) $(CPPSOURCES) $(CSOURCES) $(MSOURCES) \
1919
$(BIN)/$(EXECUTABLE_DEBUGGER) $(BIN)/$(EXECUTABLE_TRACKER)
2020

21+
# Pretty (long, space delim) names for the apps
22+
PRETTY_DEBUGGER = SPC Debugger
23+
PRETTY_TRACKER = SNES Tracker
24+
2125
# This is where source that both tracker and STD will use. NOTE THE inclusion of the forward slash ;)
2226
SHARED_DIR = shared/
2327
PROJ_DIR = ext
@@ -143,7 +147,8 @@ else ifeq ($(uname_S), Cross_Windows)
143147
CPPFLAGS += -fpermissive
144148
# NFD
145149
CPPSOURCES += $(PROJ_DIR)/NativeFileDialog/nfd_win.cpp
146-
LDFLAGS += -lole32 #-static-libgcc #-lcomctl32 -lcomdlg32
150+
# uuid needed for nfd
151+
LDFLAGS += -lole32 -luuid #-static-libgcc #-lcomctl32 -lcomdlg32
147152
BOOST_LDFLAGS := -lboost_system -lboost_filesystem
148153
# Example of static library inclusion:
149154
#BOOST_LDFLAGS := $(prefix)/lib/libboost_system.a $(prefix)/lib/libboost_filesystem.a
@@ -171,6 +176,8 @@ else ifeq ($(uname_S), Cross_Windows)
171176
EXECUTABLE_TRACKER = st.exe
172177
UNRAR = unrar.exe
173178
DEC7Z = 7zDec.exe
179+
180+
OBJECTS_TRACKER := winres.o
174181
else ifeq ($(uname_S), Windows)
175182

176183
else
@@ -212,7 +219,7 @@ $(wildcard tracker/*/*/*.cpp)
212219

213220
#
214221
OBJECTS_DEBUGGER = $(CPPSOURCES_DEBUGGER:.cpp=.o) $(MSOURCES:.m=.o) $(CSOURCES:.c=.o)
215-
OBJECTS_TRACKER = $(CPPSOURCES_TRACKER:.cpp=.o) $(MSOURCES:.m=.o) $(CSOURCES:.c=.o)
222+
OBJECTS_TRACKER += $(CPPSOURCES_TRACKER:.cpp=.o) $(MSOURCES:.m=.o) $(CSOURCES:.c=.o)
216223

217224
OBJECTS_DEBUGGER2 = $(addprefix $(OBJ)/, $(OBJECTS_DEBUGGER))
218225
OBJECTS_TRACKER2 = $(addprefix $(OBJ)/, $(OBJECTS_TRACKER))
@@ -234,25 +241,80 @@ $(BIN)/$(EXECUTABLE_DEBUGGER).app: Info.plist osx_ship.sh $(BIN)/$(EXECUTABLE_DE
234241
cp -r $(BIN)/cursors $@/Contents/Resources # Copy mouse icons
235242
bash ./osx_ship.sh $@ $(EXECUTABLE_DEBUGGER) $@/Contents/Lib
236243
touch $@
244+
# Have a pretty version
245+
cp -r $@ "$(BIN)/$(PRETTY_DEBUGGER).app"
246+
mv $@/Contents/MacOS/$(EXECUTABLE_DEBUGGER) "$(BIN)/$(PRETTY_DEBUGGER).app/Contents/MacOS/$(PRETTY_DEBUGGER)"
237247

238-
$(BIN)/$(EXECUTABLE_TRACKER).app: Info.plist osx_ship.sh $(BIN)/$(EXECUTABLE_TRACKER) $(BIN)/$(UNRAR) $(BIN)/$(DEC7Z)
248+
$(BIN)/$(EXECUTABLE_TRACKER).app: st.icns Info.plist osx_ship.sh $(BIN)/$(EXECUTABLE_TRACKER) $(BIN)/$(UNRAR) $(BIN)/$(DEC7Z)
239249
mkdir -p $@ $@/Contents/Lib $@/Contents/Resources $@/Contents/MacOS
240250
cp $(BIN)/$(EXECUTABLE_TRACKER) $@/Contents/MacOS
241251
cp Info.plist $@/Contents
242252
cp $(BIN)/$(UNRAR) $@/Contents/Resources
243253
cp $(BIN)/$(DEC7Z) $@/Contents/Resources
254+
cp st.icns $@/Contents/Resources
244255
cp -r $(BIN)/cursors $@/Contents/Resources # Copy mouse icons
245256
cp $(BIN)/tracker.spc $@/Contents/Resources # copy SPC driver
246257
bash ./osx_ship.sh $@ $(EXECUTABLE_TRACKER) $@/Contents/Lib
247258
#$@/Contents/MacOS/$(EXECUTABLE_TRACKER)
248259
touch $@
249-
260+
# Have a pretty version
261+
cp -r $@ "$(BIN)/$(PRETTY_TRACKER).app"
262+
mv $@/Contents/MacOS/$(EXECUTABLE_TRACKER) "$(BIN)/$(PRETTY_TRACKER).app/Contents/MacOS/$(PRETTY_TRACKER)"
263+
264+
# Automated creation of Mac icon pack (icns) from our PNG renders
265+
st.icns:
266+
mkdir -p $(OBJ)/st.iconset
267+
cp st-icons-png/1024-stroked-thick.png $(OBJ)/st.iconset/icon_512x512@2x.png
268+
cp st-icons-png/512-stroked-thick.png $(OBJ)/st.iconset/icon_512x512.png
269+
cp st-icons-png/512-stroked-thick.png $(OBJ)/st.iconset/icon_256x256@2x.png
270+
cp st-icons-png/256-stroked-thick.png $(OBJ)/st.iconset/icon_256x256.png
271+
cp st-icons-png/256-stroked-thick.png $(OBJ)/st.iconset/icon_128x128@2x.png
272+
cp st-icons-png/128-stroked.png $(OBJ)/st.iconset/icon_128x128.png
273+
cp st-icons-png/64.png $(OBJ)/st.iconset/icon_32x32@2x.png
274+
cp st-icons-png/32.png $(OBJ)/st.iconset/icon_32x32.png
275+
cp st-icons-png/32.png $(OBJ)/st.iconset/icon_16x16@2x.png
276+
cp st-icons-png/16.png $(OBJ)/st.iconset/icon_16x16.png
277+
iconutil -c icns -o st.icns $(OBJ)/st.iconset
278+
279+
# Automatic creation of Windows icon pack (ico) from our PNG renders
280+
# Depends on ImageMagick
281+
st.ico: st-icons-png/256-stroked-thick.png st-icons-png/64.png st-icons-png/48.png\
282+
st-icons-png/32.png st-icons-png/24.png st-icons-png/16.png Makefile
283+
rm -rf $(OBJ)/st-ico/
284+
mkdir -p $(OBJ)/st-ico
285+
convert st-icons-png/256-stroked-thick.png $(OBJ)/st-ico/256-32bit.png
286+
#convert st-icons-png/256-stroked-thick.png -depth 8 -colors 256 $(OBJ)/st-ico/256-8bit.ico
287+
#convert st-icons-png/256-stroked-thick.png -depth 4 -colors 16 $(OBJ)/st-ico/256-4bit.ico
288+
convert st-icons-png/128-stroked.png $(OBJ)/st-ico/128-32bit.png
289+
#convert st-icons-png/128-stroked.png -depth 8 -colors 256 $(OBJ)/st-ico/128-8bit.ico
290+
#convert st-icons-png/128-stroked.png -depth 4 -colors 16 $(OBJ)/st-ico/128-4bit.ico
291+
convert st-icons-png/64.png $(OBJ)/st-ico/64-32bit.png
292+
#convert st-icons-png/64.png -depth 8 -colors 256 +dither $(OBJ)/st-ico/64-8bit.png
293+
#convert st-icons-png/64.png -depth 4 -colors 16 +dither $(OBJ)/st-ico/64-4bit.png
294+
convert st-icons-png/48.png $(OBJ)/st-ico/48-32bit.png
295+
convert st-icons-png/48.png -depth 8 -colors 256 +dither $(OBJ)/st-ico/48-8bit.png
296+
convert st-icons-png/48.png -depth 4 -colors 16 +dither $(OBJ)/st-ico/48-4bit.png
297+
convert st-icons-png/32.png $(OBJ)/st-ico/32-32bit.png
298+
convert st-icons-png/32.png -depth 8 -colors 256 +dither $(OBJ)/st-ico/32-8bit.png
299+
convert st-icons-png/32.png -depth 4 -colors 16 +dither $(OBJ)/st-ico/32-4bit.png
300+
#
301+
convert st-icons-png/24.png $(OBJ)/st-ico/24-32bit.png
302+
convert st-icons-png/24.png -depth 8 -colors 256 +dither $(OBJ)/st-ico/24-8bit.png
303+
convert st-icons-png/24.png -depth 4 -colors 16 +dither $(OBJ)/st-ico/24-4bit.png
304+
convert st-icons-png/16.png $(OBJ)/st-ico/16-32bit.png
305+
convert st-icons-png/16.png -depth 8 -colors 256 +dither $(OBJ)/st-ico/16-8bit.png
306+
convert st-icons-png/16.png -depth 4 -colors 16 +dither $(OBJ)/st-ico/16-4bit.png
307+
convert $(OBJ)/st-ico/*.png st.ico
250308

251309
$(BIN)/$(EXECUTABLE_DEBUGGER): $(OBJECTS_DEBUGGER2) $(BIN)/$(UNRAR) $(BIN)/$(DEC7Z) $(LIBJDKMIDI_LIB)
252310
$(CC) $(OBJECTS_DEBUGGER2) $(LDFLAGS) -o $@
311+
# For the Windows version. and don't error out on non-windows by returning true from a subshell
312+
( cp $(BIN)/{std.exe,"$(PRETTY_DEBUGGER).exe"} ; true )
253313

254314
$(BIN)/$(EXECUTABLE_TRACKER): $(OBJECTS_TRACKER2) $(BIN)/$(UNRAR) $(BIN)/$(DEC7Z) $(LIBJDKMIDI_LIB)
255315
$(CC) $(OBJECTS_TRACKER2) $(LDFLAGS) -o $@
316+
# For the Windows version. and don't error out on non-windows by returning true from a subshell
317+
( cp $(BIN)/{st.exe,"$(PRETTY_TRACKER).exe"} ; true )
256318

257319

258320
$(BIN)/$(DEC7Z): $(PROJ_DIR)/lzma1505/C/Util/7z/$(DEC7Z) $(PROJ_DIR)/lzma1505/C/Util/7z/7zMain.c
@@ -286,13 +348,17 @@ $(OBJ)/%.o: %.cpp
286348
$(OBJ)/%.o: %.m
287349
@mkdir -p $(@D)
288350
$(OBJCC) $(OBJCFLAGS) -c $< -o $@
351+
352+
$(OBJ)/winres.o: winres.rc st.ico
353+
$(CROSS_COMPILE)windres winres.rc $(OBJ)/winres.o
289354

290355
clean:
291356
@# Remove both Linux and Windows versions of unrar and 7zdec
292357
rm -f $(BIN)/{unrar,unrar.exe}
293358
rm -f $(BIN)/{7zDec,7zDec.exe}
294359
rm -f $(BIN)/$(EXECUTABLE_DEBUGGER);
295360
rm -f $(BIN)/$(EXECUTABLE_TRACKER);
361+
rm -rf $(OBJ)
296362
find . -name "*.o" -o -name "*.d" | xargs rm -rf
297363
rm -f {$(PROJ_DIR)/lzma1505/C/Util/7z/,}{7zDec,7zDec.exe}
298364
rm -f {$(PROJ_DIR)/unrar/,}{unrar,unrar.exe}

pc/debugger/app.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ static int create_midi(void *vapp)
1313
App::App(int &argc, char **argv, int samplerate/*=44100*/)
1414
{
1515
file_system = new File_System;
16-
app_settings=new App_Settings(file_system);
1716
audio=new Audio;
1817
player=new Music_Player;
1918
::player = player;
19+
app_settings=new App_Settings(file_system);
2020

2121
handle_error(player->init(samplerate, app_settings->vars.audio_out_dev) );
2222

pc/debugger/globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ void handle_error( const char* );
1515
// 5 minutes default
1616
#define DEFAULT_SONGTIME (60*5)
1717

18-
#define PROG_NAME_VERSION_STRING "SNES Tracker Debugger v%s"
18+
#define PROG_NAME_VERSION_STRING "SPC Debugger v%s"
1919
#define CREDITS "APU emulation code from Blargg's GME and Snes_Spc 0.9.0"

pc/ext/NativeFileDialog/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define _NFD_COMMON_H
1212

1313
#define NFD_MAX_STRLEN 256
14-
#define _NFD_UNUSED(x) ((void)x)
14+
#define _NFD_UNUSED(x) ((void)x)
1515

1616
void *NFDi_Malloc( size_t bytes );
1717
void NFDi_Free( void *ptr );

pc/ext/NativeFileDialog/include/nfd.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList,
5050
const nfdchar_t *defaultPath,
5151
nfdchar_t **outPath );
5252

53+
54+
/* select folder dialog */
55+
nfdresult_t NFD_PickFolder( const nfdchar_t *defaultPath,
56+
nfdchar_t **outPath);
57+
5358
/* nfd_common.c */
5459

5560
/* get last error -- set when nfdresult_t returns NFD_ERROR */

pc/ext/NativeFileDialog/nfd_cocoa.m

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
{
2323
if ( filterList[i] == ',' || filterList[i] == ';' || filterList[i] == '\0' )
2424
{
25+
if (filterList[i] != '\0')
26+
++p_typebuf;
2527
*p_typebuf = '\0';
28+
2629
NSString *thisType = [NSString stringWithUTF8String: typebuf];
2730
[buildFilterList addObject:thisType];
2831
p_typebuf = typebuf;
@@ -116,12 +119,13 @@ static nfdresult_t AllocPathSet( NSArray *urls, nfdpathset_t *pathset )
116119
/* public */
117120

118121

119-
nfdresult_t NFD_OpenDialog( const char *filterList,
122+
nfdresult_t NFD_OpenDialog( const nfdchar_t *filterList,
120123
const nfdchar_t *defaultPath,
121124
nfdchar_t **outPath )
122125
{
123126
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
124-
127+
128+
NSWindow *keyWindow = [[NSApplication sharedApplication] keyWindow];
125129
NSOpenPanel *dialog = [NSOpenPanel openPanel];
126130
[dialog setAllowsMultipleSelection:NO];
127131

@@ -144,13 +148,15 @@ nfdresult_t NFD_OpenDialog( const char *filterList,
144148
if ( !*outPath )
145149
{
146150
[pool release];
151+
[keyWindow makeKeyAndOrderFront:nil];
147152
return NFD_ERROR;
148153
}
149154
memcpy( *outPath, utf8Path, len+1 ); /* copy null term */
150155
nfdResult = NFD_OKAY;
151156
}
152157
[pool release];
153158

159+
[keyWindow makeKeyAndOrderFront:nil];
154160
return nfdResult;
155161
}
156162

@@ -160,6 +166,7 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList,
160166
nfdpathset_t *outPaths )
161167
{
162168
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
169+
NSWindow *keyWindow = [[NSApplication sharedApplication] keyWindow];
163170

164171
NSOpenPanel *dialog = [NSOpenPanel openPanel];
165172
[dialog setAllowsMultipleSelection:YES];
@@ -178,19 +185,22 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList,
178185
if ( [urls count] == 0 )
179186
{
180187
[pool release];
188+
[keyWindow makeKeyAndOrderFront:nil];
181189
return NFD_CANCEL;
182190
}
183191

184192
if ( AllocPathSet( urls, outPaths ) == NFD_ERROR )
185193
{
186194
[pool release];
195+
[keyWindow makeKeyAndOrderFront:nil];
187196
return NFD_ERROR;
188197
}
189198

190199
nfdResult = NFD_OKAY;
191200
}
192201
[pool release];
193202

203+
[keyWindow makeKeyAndOrderFront:nil];
194204
return nfdResult;
195205
}
196206

@@ -200,7 +210,8 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList,
200210
nfdchar_t **outPath )
201211
{
202212
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
203-
213+
NSWindow *keyWindow = [[NSApplication sharedApplication] keyWindow];
214+
204215
NSSavePanel *dialog = [NSSavePanel savePanel];
205216
[dialog setExtensionHidden:NO];
206217

@@ -222,13 +233,54 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList,
222233
if ( !*outPath )
223234
{
224235
[pool release];
236+
[keyWindow makeKeyAndOrderFront:nil];
225237
return NFD_ERROR;
226238
}
227239
memcpy( *outPath, utf8Path, byteLen );
228240
nfdResult = NFD_OKAY;
229241
}
230242

243+
[pool release];
244+
[keyWindow makeKeyAndOrderFront:nil];
245+
return nfdResult;
246+
}
247+
248+
nfdresult_t NFD_PickFolder(const nfdchar_t *defaultPath,
249+
nfdchar_t **outPath)
250+
{
251+
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
252+
253+
NSWindow *keyWindow = [[NSApplication sharedApplication] keyWindow];
254+
NSOpenPanel *dialog = [NSOpenPanel openPanel];
255+
[dialog setAllowsMultipleSelection:NO];
256+
[dialog setCanChooseDirectories:YES];
257+
[dialog setCanCreateDirectories:YES];
258+
[dialog setCanChooseFiles:NO];
259+
260+
// Set the starting directory
261+
SetDefaultPath(dialog, defaultPath);
262+
263+
nfdresult_t nfdResult = NFD_CANCEL;
264+
if ( [dialog runModal] == NSModalResponseOK )
265+
{
266+
NSURL *url = [dialog URL];
267+
const char *utf8Path = [[url path] UTF8String];
268+
269+
// byte count, not char count
270+
size_t len = strlen(utf8Path);//NFDi_UTF8_Strlen(utf8Path);
271+
272+
*outPath = NFDi_Malloc( len+1 );
273+
if ( !*outPath )
274+
{
275+
[pool release];
276+
[keyWindow makeKeyAndOrderFront:nil];
277+
return NFD_ERROR;
278+
}
279+
memcpy( *outPath, utf8Path, len+1 ); /* copy null term */
280+
nfdResult = NFD_OKAY;
281+
}
231282
[pool release];
232283

284+
[keyWindow makeKeyAndOrderFront:nil];
233285
return nfdResult;
234286
}

0 commit comments

Comments
 (0)