예제 #1
0
void DialogueSupervisor::_EndLine()
{
    // Execute any scripted events that should occur after this line of dialogue has finished
    std::string line_event = _current_dialogue->GetLineEndEvent(_line_counter);
    if(!line_event.empty()) {
        MapMode::CurrentInstance()->GetEventSupervisor()->StartEvent(line_event);
    }

    if(_current_options != NULL) {
        uint32 selected_option = _dialogue_window.GetDisplayOptionBox().GetSelection();
        std::string selected_event = _current_options->GetOptionEvent(selected_option);
        if(!selected_event.empty()) {
            MapMode::CurrentInstance()->GetEventSupervisor()->StartEvent(selected_event);
        }
    }

    // Determine the next line to read
    int32 next_line = _current_dialogue->GetLineNextLine(_line_counter);
    // If this line had options, the selected option next line overrides the line's next line that we set above
    if(_current_options != NULL) {
        uint32 selected_option = _dialogue_window.GetDisplayOptionBox().GetSelection();
        next_line = _current_options->GetOptionNextLine(selected_option);
    }

    // --- Case 1: Explicitly setting the next line. Warn and end the dialogue if the line to move to is invalid
    if(next_line >= 0) {
        if(static_cast<uint32>(next_line) >= _current_dialogue->GetLineCount()) {
            IF_PRINT_WARNING(MAP_DEBUG) << "dialogue #" << _current_dialogue->GetDialogueID()
                                        << " tried to set dialogue to invalid line. Current/next line values: {" << _line_counter
                                        << ", " << next_line << "}" << std::endl;
            next_line = COMMON_DIALOGUE_END;
        }
    }
    // --- Case 2: Request to incrementing the current line. If we're incrementing past the last line, end the dialogue
    else if(next_line == COMMON_DIALOGUE_NEXT_LINE) {
        next_line = _line_counter + 1;
        if(static_cast<uint32>(next_line) >= _current_dialogue->GetLineCount())
            next_line = COMMON_DIALOGUE_END;
    }
    // --- Case 3: Request to end the current dialogue
    else if(next_line == COMMON_DIALOGUE_END) {
        // Do nothing
    }
    // --- Case 4: Unknown negative value. Warn and end dialogue
    else {
        IF_PRINT_WARNING(MAP_DEBUG) << "dialogue #" << _current_dialogue->GetDialogueID()
                                    << " unknown next line control value: " << next_line << std::endl;
        next_line = COMMON_DIALOGUE_END;
    }

    // Now either end the dialogue or move on to the next line
    if(next_line == COMMON_DIALOGUE_END) {
        EndDialogue();
    } else {
        _line_counter = next_line;
        // Reset the emote trigger flag for the next line.
        _emote_triggered = false;
        _BeginLine();
    }
}
예제 #2
0
void DialogueSupervisor::Update() {
	if (_current_dialogue == NULL) {
		IF_PRINT_WARNING(MAP_DEBUG) << "attempted to update dialogue supervisor when no dialogue was active" << endl;
		return;
	}

	switch (_state) {
		case DIALOGUE_STATE_LINE:
			_UpdateLine();
			break;
		case DIALOGUE_STATE_OPTION:
			_UpdateOptions();
			break;
		default:
			IF_PRINT_WARNING(MAP_DEBUG) << "dialogue supervisor was in an unknown state: " << _state << endl;
			_state = DIALOGUE_STATE_LINE;
			break;
	}

	// FIXME: This is disabled to prevent problems where a dialogue is necessary or has other things attached.
	// For instance: in the opening map it was possible to cancel the dialogue and be stuck there.
	// Possible fix: advancing to a 'necessary part' of the dialogue
	// Possible fix: allowing dialogues to be specified as 'non-cancelable'
	if (0 && InputManager->CancelPress()) {
		_state = DIALOGUE_STATE_LINE;
		_RestoreSprites();
		EndDialogue();
	}

} // void DialogueSupervisor::Update()
예제 #3
0
void DialogueSupervisor::_FinishLine(int32 next_line) {
	_dialogue_window._display_textbox.ClearText();
	_dialogue_window._display_options.ClearOptions();
	_state = DIALOGUE_STATE_LINE;

	// Execute any scripted events that should occur after this line of dialogue has finished
	if (_current_dialogue->GetCurrentEvent() != 0) {
		MapMode::CurrentInstance()->GetEventSupervisor()->StartEvent(_current_dialogue->GetCurrentEvent());
	}

	// Check if there are more lines of dialogue and continue on to the next line if available
	if (_current_dialogue->ReadNextLine(next_line) == true) {
		_current_options = _current_dialogue->GetCurrentOptions();
		_line_timer = _current_dialogue->GetCurrentTime();
		_dialogue_window._display_textbox.SetDisplayText(_current_dialogue->GetCurrentText());
		return;
	}

	// If this point in the function is reached, the last line of dialogue has ben read
	// Restore the status of the sprites that participated in this dialogue if necessary
	if (_current_dialogue->IsSaveState()) {
		_RestoreSprites();
	}

	EndDialogue();
} // void DialogueSupervisor::_FinishLine()
예제 #4
0
void WindowWorld::BeginDialogue(const Rect4i& padding)
{
    EndDialogue();

    const Vector2i size(
        GetSize().x - padding.x0 - padding.x1,
        GetSize().y - padding.y0 - padding.y1
    );

    m_dialogue = System::LoadDialogue("Test.Test1", size.x);
    m_dialogue->SetPosition(Vector2i(padding.x0, padding.y0));
    m_dialogue->SetSize(size);

    AddChild(m_dialogue);
}
예제 #5
0
void DialogueSupervisor::_EndLine() {
	// Determine the next line to read
	int32 next_line = _current_dialogue->GetLineNextLine(_line_counter);
	// If this line had options, the selected option next line overrides the line's next line that we set above
	if (_current_options != NULL) {
		uint32 selected_option = _dialogue_window.GetDisplayOptionBox().GetSelection();
		next_line = _current_options->GetOptionNextLine(selected_option);
	}

	// --- Case 1: Explicitly setting the next line. Warn and end the dialogue if the line to move to is invalid
	if (next_line >= 0) {
		if (static_cast<uint32>(next_line) >= _current_dialogue->GetLineCount()) {
			IF_PRINT_WARNING(BATTLE_DEBUG) << "dialogue #" << _current_dialogue->GetDialogueID()
				<< " tried to set dialogue to invalid line. Current/next line values: {" << _line_counter
				<< ", " << next_line << "}" << std::endl;
			next_line = COMMON_DIALOGUE_END;
		}
	}
	// --- Case 2: Request to incrementing the current line. If we're incrementing past the last line, end the dialogue
	else if (next_line == COMMON_DIALOGUE_NEXT_LINE) {
		next_line = _line_counter + 1;
		if (static_cast<uint32>(next_line) >= _current_dialogue->GetLineCount())
			next_line = COMMON_DIALOGUE_END;
	}
	// --- Case 3: Request to end the current dialogue
	else if (next_line == COMMON_DIALOGUE_END) {
		// Do nothing
	}
	// --- Case 4: Unknown negative value. Warn and end dialogue
	else {
		IF_PRINT_WARNING(BATTLE_DEBUG) << "dialogue #" << _current_dialogue->GetDialogueID()
			<< " unknown next line control value: " << next_line << std::endl;
		next_line = COMMON_DIALOGUE_END;
	}

	// Now either end the dialogue or move on to the next line
	if (next_line == COMMON_DIALOGUE_END) {
		EndDialogue();
	}
	else {
		_line_counter = next_line;
		_BeginLine();
	}
}