Fixed menu and added poll call to apcpp to help connecting
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#include "fixed_string.hpp"
|
#include "fixed_string.hpp"
|
||||||
#include "randomizerTypes.h"
|
#include "randomizerTypes.h"
|
||||||
#include "static_data.h"
|
#include "static_data.h"
|
||||||
|
#include "../game-interactor/GameInteractor.h"
|
||||||
|
|
||||||
//extern "C" {
|
//extern "C" {
|
||||||
// #include "include/z64item.h"
|
// #include "include/z64item.h"
|
||||||
@@ -46,6 +47,9 @@ ArchipelagoClient::ArchipelagoClient() {
|
|||||||
CVarSetInteger("archipelago_connected", 0);
|
CVarSetInteger("archipelago_connected", 0);
|
||||||
strncpy(server_address, CVarGetString(apc::SETTING_ADDRESS, apc::DEFAULT_SERVER_NAME), apc::MAX_ADDRESS_LENGTH);
|
strncpy(server_address, CVarGetString(apc::SETTING_ADDRESS, apc::DEFAULT_SERVER_NAME), apc::MAX_ADDRESS_LENGTH);
|
||||||
strncpy(slot_name, CVarGetString(apc::SETTING_NAME, ""), apc::MAX_PLAYER_NAME_LENGHT);
|
strncpy(slot_name, CVarGetString(apc::SETTING_NAME, ""), apc::MAX_PLAYER_NAME_LENGHT);
|
||||||
|
|
||||||
|
// call poll every frame
|
||||||
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([](){ArchipelagoClient::getInstance().poll();});
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchipelagoClient& ArchipelagoClient::getInstance() {
|
ArchipelagoClient& ArchipelagoClient::getInstance() {
|
||||||
@@ -275,9 +279,17 @@ void ArchipelagoClient::send_game_won() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArchipelagoClient::poll() {
|
||||||
|
if(apclient == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
apclient->poll();
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& ArchipelagoClient::get_slot_name() const {
|
const std::string& ArchipelagoClient::get_slot_name() const {
|
||||||
if(apclient == NULL) {
|
if(apclient == NULL) {
|
||||||
return;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return apclient->get_slot();
|
return apclient->get_slot();
|
||||||
@@ -316,15 +328,35 @@ void ArchipelagoWindow::ArchipelagoDrawConnectPage() {
|
|||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text(connected_text);
|
ImGui::Text(connected_text);
|
||||||
//ArchipelagoDrawConnectPageAP_ConnectionStatus con_status = AP_GetConnectionStatus();
|
|
||||||
//if(con_status == AP_ConnectionStatus::Connected) {
|
APClient::State con_state = APClient::State::DISCONNECTED;
|
||||||
// strncpy(connected_text, "Connected!", 25);
|
|
||||||
//} else if(con_status == AP_ConnectionStatus::Authenticated) {
|
if(AP_client.apclient) {
|
||||||
// strncpy(connected_text, "Authenticated!", 25);
|
con_state = AP_client.apclient->get_state();
|
||||||
//}
|
}
|
||||||
//else {
|
|
||||||
// strncpy(connected_text, "Not Connected", 25);
|
switch (con_state) {
|
||||||
//}
|
case APClient::State::DISCONNECTED: {
|
||||||
|
strncpy(connected_text, "Disconnected!", 25);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case APClient::State::SOCKET_CONNECTING: {
|
||||||
|
strncpy(connected_text, "Socket Connecting!", 25);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case APClient::State::SOCKET_CONNECTED: {
|
||||||
|
strncpy(connected_text, "Socket Connected!", 25);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case APClient::State::ROOM_INFO: {
|
||||||
|
strncpy(connected_text, "Room info Recieved!", 25);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case APClient::State::SLOT_CONNECTED: {
|
||||||
|
strncpy(connected_text, "Slot Connected!", 25);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if(ImGui::Button("scout")) {
|
if(ImGui::Button("scout")) {
|
||||||
AP_client.start_location_scouts();
|
AP_client.start_location_scouts();
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "archipelago_settings_window.h"
|
#include "archipelago_settings_window.h"
|
||||||
|
|
||||||
#include <apclient.hpp>
|
|
||||||
|
|
||||||
#include "fixed_string.hpp"
|
#include "fixed_string.hpp"
|
||||||
|
|
||||||
#include "randomizerTypes.h"
|
#include "randomizerTypes.h"
|
||||||
#include "static_data.h"
|
#include "static_data.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// forward declerations
|
||||||
|
class APClient;
|
||||||
|
|
||||||
|
|
||||||
namespace AP_Client_consts {
|
namespace AP_Client_consts {
|
||||||
static constexpr int MAX_ADDRESS_LENGTH = 64;
|
static constexpr int MAX_ADDRESS_LENGTH = 64;
|
||||||
@@ -65,6 +66,10 @@ class ArchipelagoClient{
|
|||||||
|
|
||||||
void send_game_won();
|
void send_game_won();
|
||||||
|
|
||||||
|
void poll();
|
||||||
|
|
||||||
|
std::unique_ptr<APClient> apclient;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ArchipelagoClient();
|
ArchipelagoClient();
|
||||||
|
|
||||||
@@ -72,7 +77,6 @@ class ArchipelagoClient{
|
|||||||
ArchipelagoClient(ArchipelagoClient &) = delete;
|
ArchipelagoClient(ArchipelagoClient &) = delete;
|
||||||
void operator=(const ArchipelagoClient &) = delete;
|
void operator=(const ArchipelagoClient &) = delete;
|
||||||
std::string uuid;
|
std::string uuid;
|
||||||
std::unique_ptr<APClient> apclient;
|
|
||||||
|
|
||||||
static std::shared_ptr<ArchipelagoClient> instance; // is this even used?
|
static std::shared_ptr<ArchipelagoClient> instance; // is this even used?
|
||||||
static bool initialized;
|
static bool initialized;
|
||||||
@@ -97,7 +101,7 @@ class ArchipelagoClient{
|
|||||||
|
|
||||||
void on_location_checked(int64_t location_id);
|
void on_location_checked(int64_t location_id);
|
||||||
void on_deathlink_recieved() { }; // TODO: implement me
|
void on_deathlink_recieved() { }; // TODO: implement me
|
||||||
void on_location_scouted(const std::list<APClient::NetworkItem>& network_items);
|
//void on_location_scouted(const std::list<APClient::NetworkItem>& network_items);
|
||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
std::function<void(const std::string&)> ItemRecievedCallback;
|
std::function<void(const std::string&)> ItemRecievedCallback;
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ void SohMenu::AddMenuRandomizer() {
|
|||||||
AddWidget(path, "Popout Archipelago Development Window", WIDGET_WINDOW_BUTTON)
|
AddWidget(path, "Popout Archipelago Development Window", WIDGET_WINDOW_BUTTON)
|
||||||
.CVar(CVAR_WINDOW("ArchipelagoWindow"))
|
.CVar(CVAR_WINDOW("ArchipelagoWindow"))
|
||||||
.RaceDisable(false)
|
.RaceDisable(false)
|
||||||
.WindowName("Archipelago Development")
|
.WindowName("Archipelago")
|
||||||
.Options(WindowButtonOptions().Tooltip("Enables the Archipelago development Window."));
|
.Options(WindowButtonOptions().Tooltip("Enables the Archipelago development Window."));
|
||||||
|
|
||||||
// Item Tracker
|
// Item Tracker
|
||||||
|
|||||||
Reference in New Issue
Block a user