Project

General

Profile

Bug #13745

buttons showing up on spacecenter screen when not supposed to

Added by linuxgurugamer about 7 years ago. Updated about 7 years ago.

Status:
New
Severity:
Normal
Assignee:
-
Category:
Controls and UI
Target version:
-
Start date:
02/04/2017
% Done:

0%

Version:
Platform:
Windows
Expansion:
Language:
English (US)
Mod Related:
No
Votes:
Arrow u r green
Arrow d r red

Description

Sample code designed to show a bug in KSP

This bug started when 1.2.2 was released.

Code which demonstrates the bug and a fix is located here:
https://github.com/linuxgurugamer/KSPBugDemo

I've also attached the zip from Github.

On Github, there are two files in the releases, one shows the bug, the second has code enabled which fixes the bug

Bug happens in the following case:

1. Monobehaviour class instantiated with following code:

[KSPAddon(KSPAddon.Startup.SpaceCentre, true)] // Determines when plugin starts.
public class KSPBugDemo : MonoBehaviour

2. Mod button added, button is NOT supposed to be visible on the main menu:
const ApplicationLauncher.AppScenes scenes =
ApplicationLauncher.AppScenes.FLIGHT |
ApplicationLauncher.AppScenes.MAPVIEW |
ApplicationLauncher.AppScenes.TRACKSTATION;

_appLauncherButton = applauncher.AddModApplication(
ToggleWindow, // onTrue
ToggleWindow, // onFalse
() => { }, // onHover
() => { }, // onHoverOut
() => { }, // onEnable
() => { }, // onDisable
scenes, // visibleInScenes
GameDatabase.Instance.GetTexture(TexturePath + "spacetux", false) );

Bug is that the button IS visible on the main menu, at least the first time through.

A fix is in the function:
private void FixedUpdate()

which is disabled in the demo.

My best guess is that the button isn't properly initialized when first created in this case
This can be shown by going to any other screen and then returning to the space center, the button
will be properly hidden at that point

KSPBugDemo-master.zip (27.5 KB) KSPBugDemo-master.zip [email protected] linuxgurugamer, 02/04/2017 03:58 AM

History

#1 Updated by linuxgurugamer about 7 years ago

Just some more info:

The following is from https://github.com/Ezriilc/HyperEdit/issues/12

With KSP v1.2 full release (build 1586), our "H" button (AppLauncherButton) is showing in some wrong scenes. It's not much of a problem, but it needs to be corrected, as it means something in our code is not right.

The behavior described below in my repro steps is also found with at least one other mod. See here:
http://forum.kerbalspaceprogram.com/index.php?/topic/34785-12-hyperedit-v153-sep-14-2016-cheat-teleporter-orbitplanet-editor-more/&page=57#comment-2801611

As far as I know, we're properly checking for FLIGHT or TRACKINGCENTER before showing the button, and if memory serves that is how it worked up through KSP v1.2 pre-release. See here:
https://github.com/Ezriilc/HyperEdit/blob/master/Source/Core.cs#L93
https://github.com/Ezriilc/HyperEdit/blob/master/Source/Core.cs#L194

To reproduce this, have build 1586 and HyperEdit v1.5.3 installed.
Notice that our button does not show in the Menu scene (as of yet) - this is proper.
Create/Load a sandbox save.
Notice the "H" button is showing in the Space Center scene - it should not.
Load a ship and launch to the Flight scene.
Notice the button properly shows in all the Flight scene views - this is proper.
Switch back to the Space Center scene.
Notice the button is not showing now - this is proper.
Exit to the Main Menu scene.
Notice the button is now showing here - it should not.

Also available in: Atom PDF