Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.6.0-bacon5
Auto-load last project on startup
* Application can now load the last project automatically on startup
* Disable by setting AUTO_LOAD_LAST=NO in config.xml
1.6.0-bacon4
QWERTY keyboard name entry for new projects
* Press A on the project name field to enter QWERTY keyboard mode
Expand Down
55 changes: 35 additions & 20 deletions docs/LittlePiggyTrackerConf.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,28 @@
02. [`config.xml` Example](#configxml-example)
03. [Config Values](#config-values)
04. [Screen Size](#screen-size)
05. [Screen Colors](#screen-colors)
06. [Key and Button Mapping](#key-and-button-mapping)
07. [Auto Repeat](#auto-repeat)
08. [Path](#path)
09. [Rendering](#rendering)
10. [Volume](#volume)
11. [Audio Configuration](#audio-configuration)
12. [MIDI Configuration](#midi-configuration)
13. [Log Dumping](#log-dumping)
05. [Auto-Load Last Project](#auto-load-last-project)
06. [Screen Colors](#screen-colors)
07. [Key and Button Mapping](#key-and-button-mapping)
08. [Auto Repeat](#auto-repeat)
09. [Path](#path)
10. [Rendering](#rendering)
11. [Volume](#volume)
12. [Audio Configuration](#audio-configuration)
13. [MIDI Configuration](#midi-configuration)
14. [Log Dumping](#log-dumping)
----------
14. [`mapping.xml` Guide](#mappingxml-guide)
15. [Mapping a Joystick](#mapping-a-joystick)
16. [`mapping.xml` Example](#mappingxml-example)
17. [Checking Your Work](#checking-your-work)
18. [Recovering X,Y to work on GP2X.](#recovering-xy-to-work-on-gp2x)
19. [MAC OSX mapping](#mac-osx-mapping-howto)
20. [PSP key mapping](#psp-key-mapping)
21. [GP2X key mapping](#gp2x-key-mapping)
22. [Dingoo key mapping](#dingoo-key-mapping)
23. [Caanoo key mapping](#caanoo-key-mapping)
24. [Mapping a Midi Controller](#mapping-a-midi-controller)
15. [`mapping.xml` Guide](#mappingxml-guide)
16. [Mapping a Joystick](#mapping-a-joystick)
17. [`mapping.xml` Example](#mappingxml-example)
18. [Checking Your Work](#checking-your-work)
19. [Recovering X,Y to work on GP2X.](#recovering-xy-to-work-on-gp2x)
20. [MAC OSX mapping](#mac-osx-mapping-howto)
21. [PSP key mapping](#psp-key-mapping)
22. [GP2X key mapping](#gp2x-key-mapping)
23. [Dingoo key mapping](#dingoo-key-mapping)
24. [Caanoo key mapping](#caanoo-key-mapping)
25. [Mapping a Midi Controller](#mapping-a-midi-controller)

----------

Expand Down Expand Up @@ -94,6 +95,20 @@ To have the screen bigger than the original GP2X resolution, use **SCREEMULT** t

Be careful as large values take a lot of juice and interfere with sound playback.

### Auto-Load Last Project

By default, LittleGPTracker will automatically load the last project that was open on the previous session. To disable this behavior and show the project selection dialog instead, set:

```xml
<AUTO_LOAD_LAST value='NO' />
```

To explicitly enable (default behavior):

```xml
<AUTO_LOAD_LAST value='YES' />
```

## Screen Colors

LittleGPTracker uses 6 colours to do all the drawing. If you want, you can redefine them using the following parameters:
Expand Down
7 changes: 5 additions & 2 deletions docs/wiki/What-is-LittlePiggyTracker.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,16 @@ When creating a new project, you have several options for naming:

## Multiple Projects

The Piggy supports multiple projects! Just create multiple directories in the root folder (where lgptNew and lgpt10k were found). Examples: “lgptProject1”, “lgpt*Author*Name”, “lgptSomethingElse”, “lgptWhatever”, etc. Each project directory must contain its own samples which must be stored in a sub-directory called “samples”. Lgpt will prompt you to choose one of the projects found in the root (lgpt- directories) when starting up.
The Piggy supports multiple projects! Just create multiple directories in the root folder (where lgptNew and lgpt10k were found). Examples: "lgptProject1", "lgpt*Author*Name", "lgptSomethingElse", "lgptWhatever", etc. Each project directory must contain its own samples which must be stored in a sub-directory called "samples".

By default, Lgpt will automatically load the last project that was open on the previous session. If you prefer to see the project selection screen on startup, you can disable this behavior by setting `AUTO_LOAD_LAST=NO` in your `config.xml`.

Important Points to Remember:

- Project directories **must** start with “lgpt”.
- Project directories **must** go in the root folder.
- You can reuse a previously made lgptsav.dat file.
- Lgpt will list all the projects available on startup.
- Lgpt will list all the projects available on startup if autoloading is disabled in config.xml
- The lgptsav.dat file is created automatically the project's folder using the piggy's save function (see Controls & Moves). You should not create tah file manually.
- Save often :)

Expand Down
1 change: 1 addition & 0 deletions projects/resources/BITTBOY/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Bittboy config
Re-assigned layout since no shoulder buttons
-->
<CONFIG>
<AUTO_LOAD_LAST value="YES"/> <!-- change to disable auto loading -->
<!--
<ROOTFOLDER value="/mnt/SDCARD/Tracks"/>
<SAMPLELIB value="/mnt/SDCARD/Samples"/>
Expand Down
1 change: 1 addition & 0 deletions projects/resources/CHIP/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!-- CONFIG-CHIP.xml-->
<CONFIG>
<AUTO_LOAD_LAST value="YES"/> <!-- change to disable auto loading -->
<KEY_A value="key:0:backspace" />
<KEY_B value="key:0:[-]" />
<KEY_LEFT value="key:0:left" />
Expand Down
1 change: 1 addition & 0 deletions projects/resources/DEB/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<CONFIG>
<DUMPEVENT value="YES"/>
<AUTO_LOAD_LAST value="YES"/> <!-- change to disable auto loading -->
<SCREENMULT value="2"/> <!-- increase screen size -->
<!--
<KEY_A value="key:0:x"/>
Expand Down
1 change: 1 addition & 0 deletions projects/resources/GARLIC/config.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<CONFIG>
<AUTO_LOAD_LAST value="YES"/> <!-- change to disable auto loading -->
<AUDIOBUFFERSIZE value='512'/>
<SCREENMULT value='2'/>
<KEY_A value="key:0:a" />
Expand Down
1 change: 1 addition & 0 deletions projects/resources/GARLICPLUS/config.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<CONFIG>
<AUTO_LOAD_LAST value="YES"/> <!-- change to disable auto loading -->
<ROOTFOLDER value="/mnt/mmc/MUOS/application/.lgpt/"/>
<SAMPLELIB value="/mnt/mmc/MUOS/application/.lgpt/samplelib/"/>
<SCREENMULT value='2'/>
Expand Down
1 change: 1 addition & 0 deletions projects/resources/MACOS/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<CONFIG>
<DUMPEVENT value="YES"/>
<AUTO_LOAD_LAST value="YES"/> <!-- change to disable auto loading -->
<SCREENMULT value="2"/> <!-- increase screen size -->

<KEY_A value="a"/>
Expand Down
1 change: 1 addition & 0 deletions projects/resources/MIYOO/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ create folders for your tracks and samples on the
root of your sd card.
-->
<CONFIG>
<AUTO_LOAD_LAST value="YES"/> <!-- change to disable auto loading -->
<ROOTFOLDER value="/mnt/SDCARD/Tracks"/>
<SAMPLELIB value="/mnt/SDCARD/Samples"/>
<!-- uncomment to dump events to stdout -->
Expand Down
1 change: 1 addition & 0 deletions projects/resources/PSP/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<CONFIG>
<DUMPEVENT value="YES"/><!--debug logging-->>
<AUTO_LOAD_LAST value="YES"/> <!-- change to disable auto loading -->
<SCREENMULT value="1"/> <!-- Does nothing on PSP -->

<!-- Default colors below -->
Expand Down
1 change: 1 addition & 0 deletions projects/resources/RG35XXPLUS/config.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<CONFIG>
<AUTO_LOAD_LAST value="YES"/> <!-- change to disable auto loading -->
<AUDIOBUFFERSIZE value='512'/>
<SCREENMULT value='2'/>
<KEY_A value="but:0:0" />
Expand Down
1 change: 1 addition & 0 deletions projects/resources/X64/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<CONFIG>
<DUMPEVENT value="YES"/>
<AUTO_LOAD_LAST value="YES"/> <!-- change to disable auto loading -->
<SCREENMULT value="2"/> <!-- increase screen size -->
<!--
<KEY_A value="key:0:x"/>
Expand Down
1 change: 1 addition & 0 deletions projects/resources/X86/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<CONFIG>
<DUMPEVENT value="YES"/>
<AUTO_LOAD_LAST value="YES"/> <!-- change to disable auto loading -->
<SCREENMULT value="2"/> <!-- increase screen size -->
<!--
<KEY_A value="key:0:x"/>
Expand Down
110 changes: 106 additions & 4 deletions sources/Application/AppWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static void ProjectSelectCallback(View &v, ModalView &dialog) {
SelectProjectDialog &spd = (SelectProjectDialog &)dialog;
if (dialog.GetReturnCode() > 0) {
Path selected = spd.GetSelection();
instance->SaveLastProject(selected);
instance->LoadProject(selected.GetPath().c_str());
} else {
System::GetInstance()->PostQuitMessage();
Expand Down Expand Up @@ -85,6 +86,7 @@ AppWindow::AppWindow(I_GUIWindowImp &imp) : GUIWindow(imp) {
_grooveView = 0;
_closeProject = 0;
_loadAfterSaveAsProject = 0;
_loadAfterResume = 0;
_lastA = 0;
_lastB = 0;
_mask = 0;
Expand Down Expand Up @@ -118,8 +120,23 @@ AppWindow::AppWindow(I_GUIWindowImp &imp) : GUIWindow(imp) {
_currentView = _nullView;
_nullView->SetDirty(true);

Config *config = Config::GetInstance(); // Possible to disable autoloading
const char *autoLoadEnabled = config->GetValue("AUTO_LOAD_LAST");
bool shouldAutoLoad =
(!autoLoadEnabled || // Default to yes if not in config
strcmp(autoLoadEnabled, "YES") == 0);

SelectProjectDialog *spd = new SelectProjectDialog(*_currentView);
_currentView->DoModal(spd, ProjectSelectCallback);
Path lastProjectPath = GetLastProjectPath();
if (shouldAutoLoad && lastProjectPath.Exists()) {
Trace::Log("AppWindow", "Auto-loading last project: %s",
lastProjectPath.GetPath().c_str());
_newProjectToLoad = lastProjectPath.GetPath().c_str();
_loadAfterResume = true;
delete spd;
} else { // Show project selection dialog
_currentView->DoModal(spd, ProjectSelectCallback);
}

memset(_charScreen, ' ', 1200);
memset(_preScreen, ' ', 1200);
Expand Down Expand Up @@ -488,7 +505,7 @@ bool AppWindow::onEvent(GUIEvent &event) {
if (_loadAfterSaveAsProject) {
CloseProject();
_isDirty = true;
LoadProject(_newProjectToLoad);
LoadProject(_newProjectToLoad.c_str());
}
#ifdef _SHOW_GP2X_
Redraw();
Expand All @@ -500,7 +517,12 @@ bool AppWindow::onEvent(GUIEvent &event) {
};

void AppWindow::onUpdate() {
// Redraw() ;
if (_loadAfterResume) {
_loadAfterResume = false;
_isDirty = true;
LoadProject(_newProjectToLoad.c_str());
return;
}
Flush();
};

Expand Down Expand Up @@ -577,7 +599,7 @@ void AppWindow::Update(Observable &o, I_ObservableData *d) {
case VET_SAVEAS_PROJECT: {
char *name = (char *)ve->GetData();
_loadAfterSaveAsProject = true;
strcpy(_newProjectToLoad, name);
_newProjectToLoad = name;
break;
}

Expand Down Expand Up @@ -624,3 +646,83 @@ void AppWindow::Print(char *line) {
};

void AppWindow::SetColor(ColorDefinition cd) { colorIndex_ = cd; };

Path AppWindow::GetLastProjectPath() {
Path lastProjectFile(LAST_PROJECT_NAME);
FileSystem *fs = FileSystem::GetInstance();
I_File *file = fs->Open(lastProjectFile.GetPath().c_str(), "r");

if (!file) {
return Path();
}

// Get file size
file->Seek(0, SEEK_END);
int length = file->Tell();

if (length <= 0) {
file->Close();
delete file;
return Path();
}

// Allocate buffer and seek back to start
char *buffer = (char *)SYS_MALLOC(length + 1);
memset(buffer, 0, length + 1);

file->Seek(0, SEEK_SET); // Seek back to start
int bytes = file->Read(buffer, 1, length); // Read full length
file->Close();
delete file;

if (bytes <= 0) {
Trace::Error("GetLastProject: Failed to read last project file");
SYS_FREE(buffer);
return Path();
}

buffer[bytes] = 0; // Null terminate

// Remove newline if present
int len = strlen(buffer);
if (len > 0 && buffer[len-1] == '\n') {
buffer[len-1] = 0;
}

Path result;
if (strlen(buffer) > 0) {
if (strstr(buffer, "lgpt_") != NULL) { // Ensure it's an lgpt project
result = Path(buffer);
} else {
Trace::Error("GetLastProject: Invalid project path format: %s",
buffer);
}
}
if (!result.IsDirectory()) {
Trace::Error("GetLastProject: path does not exist: %s", result.GetPath().c_str());
}

SYS_FREE(buffer);
return result;
}

void AppWindow::SaveLastProject(const Path &p) {
Path lastProjectFile(LAST_PROJECT_NAME);
FileSystem *fs = FileSystem::GetInstance();
I_File *file = fs->Open(lastProjectFile.GetPath().c_str(), "w");

if (!file) {
Trace::Error("SaveLastProject: Failed to open %s for writing",
LAST_PROJECT_NAME);
return;
}

std::string pathStr = p.GetPath();
file->Write(pathStr.c_str(), 1, pathStr.length());
file->Write("\n", 1, 1);
file->Close();
delete file;

Trace::Log("SaveLastProject", "Saved last project: %s",
p.GetPath().c_str());
}
7 changes: 6 additions & 1 deletion sources/Application/AppWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class AppWindow : public GUIWindow, I_Observer, Status {
public:
static AppWindow *Create(GUICreateWindowParams &);
void LoadProject(const Path &path);
void SaveLastProject(const Path &p);
void CloseProject();

virtual void Clear(bool all = false);
Expand Down Expand Up @@ -77,12 +78,13 @@ class AppWindow : public GUIWindow, I_Observer, Status {
bool _isDirty;
bool _closeProject;
bool _loadAfterSaveAsProject;
bool _loadAfterResume;
bool _shouldQuit;
unsigned short _mask;
unsigned long _lastA;
unsigned long _lastB;
char _statusLine[80];
char _newProjectToLoad[80];
std::string _newProjectToLoad;
unsigned char _charScreen[1200];
unsigned char _charScreenProp[1200];
unsigned char _preScreen[1200];
Expand All @@ -102,13 +104,16 @@ class AppWindow : public GUIWindow, I_Observer, Status {
static GUIColor rownumberColor_;
static GUIColor rownumber2Color_;
static GUIColor majorbeatColor_;
#define LAST_PROJECT_NAME "bin:last_project"

ColorDefinition colorIndex_;

static int charWidth_;
static int charHeight_;

SysMutex drawMutex_;

Path GetLastProjectPath();
};

#endif
2 changes: 1 addition & 1 deletion sources/Application/Model/Project.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#define PROJECT_NUMBER "1"
#define PROJECT_RELEASE "6"
#define BUILD_COUNT "0-bacon4"
#define BUILD_COUNT "0-bacon5"

#define MAX_TAP 3

Expand Down