Cleanup SectorView, move nav target sound to pigui
- Moved playing the 'target selected' sound to PiGui instead of C++ - Removed several unused functions/methods from SectorView - Removed the WorldView method handler previously responsible for playing the target selected sound - Better documentation and behavior for pigui.playSfxmaster
parent
f64e78d62f
commit
f748b0a2e9
|
@ -164,9 +164,11 @@ function ChatForm:AddNavButton (target)
|
|||
if ui.coloredSelectedButton(l.SET_AS_TARGET, self.style.buttonSize, false, colors.buttonBlue, nil, true) then
|
||||
if target:isa("Body") and target:IsDynamic() then
|
||||
Game.player:SetNavTarget(target)
|
||||
ui.playSfx("OK")
|
||||
elseif Game.system and target:IsSameSystem(Game.system.path) then
|
||||
if target.bodyIndex then
|
||||
Game.player:SetNavTarget(Space.GetBody(target.bodyIndex))
|
||||
ui.playSfx("OK")
|
||||
end
|
||||
elseif not Game.InHyperspace() then
|
||||
Game.sectorView:SwitchToPath(target:GetStarSystem().path)
|
||||
|
|
|
@ -66,11 +66,11 @@ local function sortByPlayerDistance(a,b)
|
|||
if a.body == nil then
|
||||
return false;
|
||||
end
|
||||
|
||||
|
||||
if b.body == nil then
|
||||
return false;
|
||||
end
|
||||
|
||||
|
||||
return a.body:DistanceTo(Game.player) < b.body:DistanceTo(Game.player)
|
||||
end
|
||||
|
||||
|
@ -142,6 +142,7 @@ local function showEntry(entry, indent, sortFunction)
|
|||
ui.sameLine()
|
||||
if ui.selectable(label or "UNKNOWN", is_target, {"SpanAllColumns"}) then
|
||||
Game.player:SetNavTarget(body)
|
||||
ui.playSfx("OK")
|
||||
end
|
||||
if ui.isItemHovered() and ui.isMouseClicked(1) then
|
||||
ui.openDefaultRadialMenu(body)
|
||||
|
|
|
@ -434,9 +434,11 @@ local function displayOnScreenObjects()
|
|||
if (isShip or isSystemBody and mainObject.ref.physicsBody) and ui.selectable(lc.SET_AS_TARGET, false, {}) then
|
||||
if isSystemBody then
|
||||
player:SetNavTarget(mainObject.ref.physicsBody)
|
||||
ui.playSfx("OK")
|
||||
else
|
||||
if combatTarget == mainObject.ref then player:SetCombatTarget(nil) end
|
||||
player:SetNavTarget(mainObject.ref)
|
||||
ui.playSfx("OK")
|
||||
end
|
||||
end
|
||||
if isShip and ui.selectable(lc.SET_AS_COMBAT_TARGET, false, {}) then
|
||||
|
|
|
@ -654,7 +654,7 @@ ui.HoveredFlags = pigui.HoveredFlags
|
|||
|
||||
-- FINALLY OUT OF Pi.cpp! BEGONE!
|
||||
ui.playBoinkNoise = function ()
|
||||
ui.playSfx("Click", 0.3, 0.3)
|
||||
ui.playSfx("Click", 0.3)
|
||||
end
|
||||
|
||||
local shouldShowRadialMenu = false
|
||||
|
@ -684,7 +684,8 @@ local radial_menu_actions_station = {
|
|||
action=function(target)
|
||||
local msg = Game.player:RequestDockingClearance(target)
|
||||
Game.AddCommsLogLine(msg, target.label)
|
||||
Game.player:SetNavTarget(target)
|
||||
Game.player:SetNavTarget(target)
|
||||
ui.playSfx("OK")
|
||||
end},
|
||||
{icon=ui.theme.icons.autopilot_dock, tooltip=lc.AUTOPILOT_DOCK_WITH_STATION,
|
||||
action=function(target)
|
||||
|
@ -692,6 +693,7 @@ local radial_menu_actions_station = {
|
|||
Game.player:SetFlightControlState("CONTROL_AUTOPILOT")
|
||||
Game.player:AIDockWith(target)
|
||||
Game.player:SetNavTarget(target)
|
||||
ui.playSfx("OK")
|
||||
else
|
||||
Game.AddCommsLogLine(lc.NO_AUTOPILOT_INSTALLED)
|
||||
end
|
||||
|
@ -705,6 +707,7 @@ local radial_menu_actions_all_bodies = {
|
|||
Game.player:SetFlightControlState("CONTROL_AUTOPILOT")
|
||||
Game.player:AIFlyTo(target)
|
||||
Game.player:SetNavTarget(target)
|
||||
ui.playSfx("OK")
|
||||
else
|
||||
Game.AddCommsLogLine(lc.NO_AUTOPILOT_INSTALLED)
|
||||
end
|
||||
|
@ -719,7 +722,8 @@ local radial_menu_actions_systembody = {
|
|||
Game.player:SetFlightControlState("CONTROL_AUTOPILOT")
|
||||
Game.player:AIEnterLowOrbit(target)
|
||||
Game.player:SetNavTarget(target)
|
||||
else
|
||||
ui.playSfx("OK")
|
||||
else
|
||||
Game.AddCommsLogLine(lc.NO_AUTOPILOT_INSTALLED)
|
||||
end
|
||||
end},
|
||||
|
@ -729,7 +733,8 @@ local radial_menu_actions_systembody = {
|
|||
Game.player:SetFlightControlState("CONTROL_AUTOPILOT")
|
||||
Game.player:AIEnterMediumOrbit(target)
|
||||
Game.player:SetNavTarget(target)
|
||||
else
|
||||
ui.playSfx("OK")
|
||||
else
|
||||
Game.AddCommsLogLine(lc.NO_AUTOPILOT_INSTALLED)
|
||||
end
|
||||
end},
|
||||
|
@ -739,7 +744,8 @@ local radial_menu_actions_systembody = {
|
|||
Game.player:SetFlightControlState("CONTROL_AUTOPILOT")
|
||||
Game.player:AIEnterHighOrbit(target)
|
||||
Game.player:SetNavTarget(target)
|
||||
else
|
||||
ui.playSfx("OK")
|
||||
else
|
||||
Game.AddCommsLogLine(lc.NO_AUTOPILOT_INSTALLED)
|
||||
end
|
||||
end},
|
||||
|
|
|
@ -94,6 +94,7 @@ local function setTarget(body)
|
|||
player:SetCombatTarget(body)
|
||||
else
|
||||
player:SetNavTarget(body)
|
||||
ui.playSfx("OK")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -209,6 +210,7 @@ local function displayOnScreenObjects()
|
|||
player:SetCombatTarget(b)
|
||||
else
|
||||
player:SetNavTarget(b)
|
||||
ui.playSfx("OK")
|
||||
end
|
||||
if ui.ctrlHeld() then
|
||||
-- also set setspeed target on ctrl-click
|
||||
|
|
|
@ -70,7 +70,6 @@ SectorView::SectorView(Game *game) :
|
|||
GotoSystem(m_current);
|
||||
m_pos = m_posMovingTo;
|
||||
|
||||
m_matchTargetToSelection = true;
|
||||
m_automaticSystemSelection = true;
|
||||
m_detailBoxVisible = DETAILBOX_INFO;
|
||||
m_toggledFaction = false;
|
||||
|
@ -100,7 +99,6 @@ SectorView::SectorView(const Json &jsonObj, Game *game) :
|
|||
m_current = SystemPath::FromJson(sectorViewObj["current"]);
|
||||
m_selected = SystemPath::FromJson(sectorViewObj["selected"]);
|
||||
m_hyperspaceTarget = SystemPath::FromJson(sectorViewObj["hyperspace"]);
|
||||
m_matchTargetToSelection = sectorViewObj["match_target_to_selection"];
|
||||
m_automaticSystemSelection = sectorViewObj["automatic_system_selection"];
|
||||
m_detailBoxVisible = sectorViewObj["detail_box_visible"];
|
||||
} catch (Json::type_error &) {
|
||||
|
@ -230,7 +228,6 @@ void SectorView::SaveToJson(Json &jsonObj)
|
|||
m_hyperspaceTarget.ToJson(hyperspaceSystemObj);
|
||||
sectorViewObj["hyperspace"] = hyperspaceSystemObj; // Add hyperspace system object to sector view object.
|
||||
|
||||
sectorViewObj["match_target_to_selection"] = m_matchTargetToSelection;
|
||||
sectorViewObj["automatic_system_selection"] = m_automaticSystemSelection;
|
||||
sectorViewObj["detail_box_visible"] = m_detailBoxVisible;
|
||||
|
||||
|
@ -306,20 +303,13 @@ void SectorView::Draw3D()
|
|||
void SectorView::SetHyperspaceTarget(const SystemPath &path)
|
||||
{
|
||||
m_hyperspaceTarget = path;
|
||||
m_matchTargetToSelection = false;
|
||||
onHyperspaceTargetChanged.emit();
|
||||
}
|
||||
|
||||
void SectorView::FloatHyperspaceTarget()
|
||||
{
|
||||
m_matchTargetToSelection = true;
|
||||
}
|
||||
|
||||
void SectorView::ResetHyperspaceTarget()
|
||||
{
|
||||
SystemPath old = m_hyperspaceTarget;
|
||||
m_hyperspaceTarget = Pi::game->GetSpace()->GetStarSystem()->GetStars()[0]->GetPath();
|
||||
FloatHyperspaceTarget();
|
||||
|
||||
if (!old.IsSameSystem(m_hyperspaceTarget)) {
|
||||
onHyperspaceTargetChanged.emit();
|
||||
|
@ -1265,14 +1255,6 @@ double SectorView::GetCenterDistance()
|
|||
}
|
||||
}
|
||||
|
||||
void SectorView::LockHyperspaceTarget(bool lock)
|
||||
{
|
||||
if (lock) {
|
||||
SetHyperspaceTarget(GetSelected());
|
||||
} else {
|
||||
FloatHyperspaceTarget();
|
||||
}
|
||||
}
|
||||
std::vector<SystemPath> SectorView::GetNearbyStarSystemsByName(std::string pattern)
|
||||
{
|
||||
std::vector<SystemPath> result;
|
||||
|
|
|
@ -37,8 +37,6 @@ public:
|
|||
void SwitchToPath(const SystemPath &path);
|
||||
SystemPath GetHyperspaceTarget() const { return m_hyperspaceTarget; }
|
||||
void SetHyperspaceTarget(const SystemPath &path);
|
||||
void FloatHyperspaceTarget();
|
||||
void LockHyperspaceTarget(bool lock);
|
||||
void ResetHyperspaceTarget();
|
||||
void GotoSector(const SystemPath &path);
|
||||
void GotoSystem(const SystemPath &path);
|
||||
|
@ -163,7 +161,6 @@ private:
|
|||
bool m_zoomView = false;
|
||||
|
||||
SystemPath m_hyperspaceTarget;
|
||||
bool m_matchTargetToSelection;
|
||||
bool m_automaticSystemSelection;
|
||||
|
||||
bool m_drawUninhabitedLabels;
|
||||
|
|
|
@ -107,9 +107,6 @@ void WorldView::InitObject()
|
|||
shipView.reset(new ShipViewController(this));
|
||||
shipView->Init();
|
||||
|
||||
m_onPlayerChangeTargetCon =
|
||||
Pi::player->GetPlayerController()->onChangeTarget.connect(sigc::mem_fun(this, &WorldView::OnPlayerChangeTarget));
|
||||
|
||||
m_onToggleHudModeCon = InputBindings.toggleHudMode->onPress.connect(sigc::mem_fun(this, &WorldView::OnToggleLabels));
|
||||
m_onIncTimeAccelCon = InputBindings.increaseTimeAcceleration->onPress.connect(sigc::mem_fun(this, &WorldView::OnRequestTimeAccelInc));
|
||||
m_onDecTimeAccelCon = InputBindings.decreaseTimeAcceleration->onPress.connect(sigc::mem_fun(this, &WorldView::OnRequestTimeAccelDec));
|
||||
|
@ -117,7 +114,6 @@ void WorldView::InitObject()
|
|||
|
||||
WorldView::~WorldView()
|
||||
{
|
||||
m_onPlayerChangeTargetCon.disconnect();
|
||||
m_onToggleHudModeCon.disconnect();
|
||||
m_onIncTimeAccelCon.disconnect();
|
||||
m_onDecTimeAccelCon.disconnect();
|
||||
|
@ -285,17 +281,6 @@ static void PlayerPayFine()
|
|||
}
|
||||
*/
|
||||
|
||||
void WorldView::OnPlayerChangeTarget()
|
||||
{
|
||||
Body *b = Pi::player->GetNavTarget();
|
||||
if (b) {
|
||||
Sound::PlaySfx("OK");
|
||||
Ship *s = b->IsType(Object::HYPERSPACECLOUD) ? static_cast<HyperspaceCloud *>(b)->GetShip() : 0;
|
||||
if (!s || !m_game->GetSectorView()->GetHyperspaceTarget().IsSameSystem(s->GetHyperspaceDest()))
|
||||
m_game->GetSectorView()->FloatHyperspaceTarget();
|
||||
}
|
||||
}
|
||||
|
||||
int WorldView::GetActiveWeapon() const
|
||||
{
|
||||
using CamType = ShipViewController::CamType;
|
||||
|
|
|
@ -111,7 +111,6 @@ private:
|
|||
void DrawCombatTargetIndicator(const Indicator &target, const Indicator &lead, const Color &c);
|
||||
void DrawEdgeMarker(const Indicator &marker, const Color &c);
|
||||
|
||||
void OnPlayerChangeTarget();
|
||||
/// Handler for "requestTimeAccelerationInc" event
|
||||
void OnRequestTimeAccelInc();
|
||||
/// Handler for "requestTimeAccelerationDec" event
|
||||
|
@ -125,7 +124,6 @@ private:
|
|||
|
||||
bool m_labelsOn;
|
||||
|
||||
sigc::connection m_onPlayerChangeTargetCon;
|
||||
sigc::connection m_onToggleHudModeCon;
|
||||
sigc::connection m_onIncTimeAccelCon;
|
||||
sigc::connection m_onDecTimeAccelCon;
|
||||
|
|
|
@ -2274,12 +2274,23 @@ static int l_pigui_input_text(lua_State *l)
|
|||
return 2;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: pigui.playSfx
|
||||
|
||||
Play the specified sound effect, optionally with a different volume on the
|
||||
left/right side.
|
||||
|
||||
Parameters:
|
||||
name - string, name of the sound effect to play
|
||||
left - optional number, volume on the left speaker/ear. Defaults to 1.0
|
||||
right - optional number, volume on the right speaker/ear. Defaults to the left volume.
|
||||
*/
|
||||
static int l_pigui_play_sfx(lua_State *l)
|
||||
{
|
||||
PROFILE_SCOPED()
|
||||
std::string name = LuaPull<std::string>(l, 1);
|
||||
double left = LuaPull<float>(l, 2);
|
||||
double right = LuaPull<float>(l, 3);
|
||||
double left = LuaPull<float>(l, 2, 1.0);
|
||||
double right = LuaPull<float>(l, 3, left);
|
||||
Sound::PlaySfx(name.c_str(), left, right, false);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ void LuaObject<SectorView>::RegisterClass()
|
|||
.AddFunction("SetDrawVerticalLines", &SectorView::SetDrawVerticalLines)
|
||||
.AddFunction("SetDrawOutRangeLabels", &SectorView::SetDrawOutRangeLabels)
|
||||
.AddFunction("SetAutomaticSystemSelection", &SectorView::SetAutomaticSystemSelection)
|
||||
.AddFunction("SetLockHyperspaceTarget", &SectorView::LockHyperspaceTarget)
|
||||
.AddFunction("SetFactionVisible", &SectorView::SetFactionVisible)
|
||||
.AddFunction("ClearRoute", &SectorView::ClearRoute)
|
||||
.AddFunction("GetSelectedSystemPath", &SectorView::GetSelected)
|
||||
|
|
Loading…
Reference in New Issue