Skip to content

Commit

Permalink
Change "Append scene" to "Add scene" and jump to the new scene right …
Browse files Browse the repository at this point in the history
…away

part of #38
  • Loading branch information
vooku committed Mar 28, 2020
1 parent ab00a69 commit 9e033a0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 21 deletions.
15 changes: 6 additions & 9 deletions skinny/src/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace skinny {
const std::string Gui::Btn::NEXT = "Next scene";
const std::string Gui::Btn::PREV = "Previous scene";
const std::string Gui::Btn::JUMP = "Jump to scene";
const std::string Gui::Btn::APPEND = "Append scene";
const std::string Gui::Btn::NEW = "New scene";
const std::string Gui::Btn::SAVE = "Save";
const std::string Gui::Btn::SAVE_AS = "Save as";
const std::string Gui::Btn::LOAD = "Load";
Expand Down Expand Up @@ -195,7 +195,6 @@ void Gui::onLayerButton(ofxDatGuiButtonEvent e)
layerDescription.path = openFileResult.getPath();
else
layerDescription = { static_cast<unsigned int>(idx), openFileResult.getPath() };
Status::instance().load = true;
Status::instance().loadDir = LoadDir::Current;
}
}
Expand Down Expand Up @@ -232,26 +231,24 @@ void Gui::onControlButton(ofxDatGuiButtonEvent e)
ofLog(OF_LOG_WARNING, "Cannot load config file %s, creating default scene instead.", openFileResult.fileName.c_str());
showDescription_.appendScene();
}
Status::instance().load = true;
Status::instance().loadDir = LoadDir::Current;
}
};

const auto name = e.target->getName();
if (name == Btn::NEXT) {
Status::instance().load = true;
Status::instance().loadDir = LoadDir::Forward;
} else if (name == Btn::PREV) {
Status::instance().load = true;
Status::instance().loadDir = LoadDir::Backward;
} else if (name == Btn::JUMP) {
Status::instance().load = true;
Status::instance().loadDir = LoadDir::Jump;
// # TODO jump to
Status::instance().jumpToIndex = getJumpToIndex();
}
else if (name == Btn::APPEND) {
else if (name == Btn::NEW) {
showDescription_.appendScene();
jumpToInput_->setLabel(buildJumpToLabel(showDescription_.currentIdx_ + 1, showDescription_.getSize()));
Status::instance().loadDir = LoadDir::Jump;
Status::instance().jumpToIndex = showDescription_.getSize() - 1;
} else if (name == Btn::LOAD) {
load();
} else if (name == Btn::SAVE) {
Expand Down Expand Up @@ -438,7 +435,7 @@ void Gui::setupControlPanel(glm::ivec2& pos)
jumpToInput_->setLabel(buildJumpToLabel(0, 0));
jumpToInput_->setText("0");
controlButtons_.push_back(controlPanel_->addButton(Btn::JUMP));
controlButtons_.push_back(controlPanel_->addButton(Btn::APPEND));
controlButtons_.push_back(controlPanel_->addButton(Btn::NEW));
controlPanel_->addBreak();
controlButtons_.push_back(controlPanel_->addButton(Btn::SAVE));
controlButtons_.push_back(controlPanel_->addButton(Btn::SAVE_AS));
Expand Down
2 changes: 1 addition & 1 deletion skinny/src/Gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Gui {
static const std::string NEXT;
static const std::string PREV;
static const std::string JUMP;
static const std::string APPEND;
static const std::string NEW;
static const std::string SAVE;
static const std::string SAVE_AS;
static const std::string LOAD;
Expand Down
8 changes: 1 addition & 7 deletions skinny/src/Status.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,9 @@ class Status
return status;
}

void resetLoad()
{
load = false;
loadDir = LoadDir::None;
}

bool exit = false; //!< The app should exit.
bool load = false; //!< Load a scene according to loadDir.
LoadDir loadDir = LoadDir::None;
int jumpToIndex = 0; //!< In the case of LoadDir::Jump

private:
Status() = default;
Expand Down
7 changes: 3 additions & 4 deletions skinny/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ void ofApp::update()
//return;
}

if (Status::instance().load) {
if (Status::instance().loadDir != LoadDir::None) {
reload();
Status::instance().resetLoad();
}

show_->update();
Expand Down Expand Up @@ -132,7 +131,6 @@ void ofApp::newMidiMessage(ofxMidiMessage & msg)
}

if (msg.status == MIDI_NOTE_ON && msg.pitch == showDescription_.getSwitchNote()) {
Status::instance().load = true;
Status::instance().loadDir = LoadDir::Forward;
}
else {
Expand Down Expand Up @@ -201,7 +199,7 @@ bool ofApp::reload()

gui_.displayMessage("Loading...");

const auto shifted = showDescription_.shift(Status::instance().loadDir, gui_.getJumpToIndex());
const auto shifted = showDescription_.shift(Status::instance().loadDir, Status::instance().jumpToIndex);
if (!shifted && Status::instance().loadDir != LoadDir::Current) {
gui_.resetJumpToIndex();
return false;
Expand All @@ -216,6 +214,7 @@ bool ofApp::reload()
ofLog(OF_LOG_WARNING, "Scene %s encountered loading problems.", showDescription_.currentScene().name.c_str());
}

Status::instance().loadDir = LoadDir::None;
return true;
}

Expand Down

0 comments on commit 9e033a0

Please sign in to comment.