KSP-KOS / KOS

Fully programmable autopilot mod for KSP. Originally By Nivekk
Other
698 stars 230 forks source link

Weird formatting issue - in-game terminal #2219

Open elishaday54 opened 6 years ago

elishaday54 commented 6 years ago

Not entirely sure if this is an issue with kOS or something I can fix myself, but I figured I'd at least ask for help.

Also ignore what I typed into the console, that was just to demonstrate the error.

As shown in the following image, the text is indented though the cursor is not. Text is also cut off on the edges of the screen. (img 1) 1

Resizing the terminal doesn't change either issues (img 2 & 3): 2 3

This is kOS version 1.1.5.1 (the backport for ksp 1.2.2), on Windows x64 and ksp 1.2.2. Accompanied with RSS/RO/RP-0.

Dunbaratu commented 6 years ago

This is very weird. I'm running on the same setup and not getting this problem at all. There is a bit of margin on the left, but not to the extent that you're seeing here.

I have no idea what is making it do this. Does rebooting the kOS part so it clears the screen and shows the opening message fix it?

elishaday54 commented 6 years ago

Nope, rebooting kOS, restarting ksp - none of that works. I was originally on kOS v1.1.3.1 (which is what CKAN downloaded) and so I thought it might've been an issue with that build and tried updating to 1.1.5.1 but the same thing persists. I'll get a mod list for my install if that will help?

Dunbaratu commented 6 years ago

Was this a problem caused by updating to kOS v1.1.5.1 or did it happen in kOS v1.1.3.1 too?

elishaday54 commented 6 years ago

Sorry that wasn't clear, same error in both versions.

elishaday54 commented 6 years ago

Though considering that, I suppose it's most likely an incompatibility with another mod I have installed as opposed to an error with kOS.

elishaday54 commented 6 years ago

Mod list on my install:

KSP: 1.2.2 (Win64) - Unity: 5.4.0p4 - OS: Windows 10  (10.0.0) 64bit
000_AT_Utils - 1.4.2
USI Tools - 0.8.18
Advanced Jet Engine - 2.8
AllYAllContinued - 0.10.2
B9 Animation Modules - 1.0.5
B9 Part Switch - 1.7.1
B9 Aerospace - 6.3.1
B9 Aerospace - 6.3.1
B9 Aerospace HX Parts - 6.3.1
B9 Aerospace Procedural Parts - 0.40.11
Better Science Labs Continued - 0.1.9.2
Bon Voyage - 0.12
Community Category Kit - 1.2.2
Community Resource Pack - 0.6.6
CommunityTechTree - 3.0.3
Connected Living Space - 1.2.4.2
Contract Configurator - 1.22.2
Contract Pack: Clever Sats - 1.4
Contract Pack: Field Research - 1.2.1
Contract Pack: Historical Progression - 1.6
Contract Pack: Kerbal Academy - 1.1.7
Contract Pack: Bases and Stations - 3.7.0.1
Contract Pack: RemoteTech - 2.1.3
Contract Pack: Grand Tour Contracts - 0.1.10.3
Rover Missions - 0.1.7
Contract Pack: Unmanned Contracts - 0.3.27
Contract Pack: Tourism Plus - 1.5.2
CryoEngines - 0.4.6
CustomBarnKit - 1.1.16
Deadly Reentry - 7.6.0.1
DistantObjectEnhancement - 1.8.1
DMagic Orbital Science - 1.3.0.8
CapCom Mission Control On The Go - 1.0.2.5
Contract Parser - 1.0.5
Progress Parser - 1.0.6
EVAEnhancementsContinued - 0.1.9
EVA Struts - 1.0.3
Ferram Aerospace Research - 0.15.8.1
Firespitter - 7.5.1
FMRS (Flight Manager For Reusable Stages) - 1.2.4
Forgotten Real Engines - 0.7.1
GroundConstruction - 1.1.2.1
Interstellar Fuel Switch - 2.5.1
RasterPropMonitor - 0.28
Kerbal Attachment System - 0.6.2
KerbalAtomics - 0.3.5
Kerbal Construction Time - 1.3.9
Kerbal Engineer Redux - 1.1.2.8
Kerbal Joint Reinforcement - 3.3.2
Kerbal Inventory System - 1.4.4
kOS - 1.1.5.1
KSP-AVC Plugin - 1.1.6.2
KWRocketryRedux - 3.1.4
Lithobrake Exploration Technologies - 0.4
MagiCore - 1.3
Infernal Robots - 2.0.10
ModularFlightIntegrator - 1.2.4
Docking Port Alignment Indicator - 6.5.2
NearFutureConstruction - 0.7.6
NearFutureElectrical - 0.8.7
NearFuturePropulsion - 0.8.7
NearFutureSolar - 0.7.2
NearFutureSpacecraft - 0.6.3
NRAP - 1.5.5.1
Kerbal Planetary Base Systems - 1.4.2
PlanetShine - 0.2.5.2
Precise Maneuver - 2.2.5
Procedural Parts - 1.2.11
RCS Build Aid - 0.9.1
RealChute - 1.4.3
RealFuels - 12.2.4
RealismOverhaul - 11.5.1
Real Scale Boosters - 0.15
RealSolarSystem - 12.0
Real Time Clock 2 - 1.3
Recovery Controller - 0.0.1
ReentryParticleEffect - 1.2.0.1
RemoteTech - 1.8.6
DeepFreeze Continued... - 0.23.4
RetractableLiftingSurface - 0.1.3
RSSDateTime - 1.1
Saturatable RW - 1.12
SafeChute - 2.1.6
SCANsat - 1.1.6.11
ScrapYard - 0.9.4.51
SolverEngines - 3.1
SpaceY Expanded - 1.3.1
SpaceY Lifters - 1.16
StageRecovery - 1.7.2
StationScienceContinued - 2.2.1
Strategia - 1.5
SXTContinued - 0.3.12.1
TAC Fuel Balancer - 2.12
TakeCommandContinued - 1.4.8
TestFlight - 1.8.0.1
TAC Life Support - 0.13
Trajectories - 1.6.6
Kerbal Alarm Clock - 3.8.4
Transfer Window Planner - 1.6.1
TweakScale - 2.3.4
USI Core - 0.3.10
Asteroid Recycling Tech - 0.9.9
USI Exploration Pack - 0.7.3
Freight Transport Tech - 0.6.8
Konstruction - 0.1.12
Malemute Rover - 0.2.8
MKS - 0.50.18
NuclearRockets - 0.3.9
Universal Storage - 1.3.0.1
EVAParachutesAndEjectionSeats - 0.1.13
VenStockRevamp - 1.9.5
KSP Interstellar Extended - 1.13.10
Waypoint Manager - 2.6.2
[x] Science! - 5.6
Dunbaratu commented 6 years ago

I have a hard time imagining what another mod could be doing that would cause this.

The placement of those items within the window is, quite literally, hardcoded, like so:

Choosing the location to fix the rectangle where the text is drawn:

            GUI.BeginGroup(new Rect(28, 38, screen.ColumnCount * charWidth + 2, screen.RowCount * charHeight + 2)); // +2's for the sake of safety margin

(Those numbers, 28, and 38, are the hardcoded indent in pixels from the window frame, of the bounding box where the content text is drawn.)

Then the text is drawn with this loop, one iteration per row:


                for (int row = 0; row < rowsToPaint; row++)
                {
                    // At first the screen is filled with null chars.  So if you do something like
                    // PRINT "AAA" AT (4,0) you can get a row of the screen like so "\0\0\0\0AAA".
                    // When the font renderer prints null chars, they don't advance the cursor
                    // even in a monospoaced font (so "\0\0\0\0AAA" looks just like "AAA" instead
                    // of looking like "    AAA" when printed).  The reason for the "cooking" of
                    // the string below is to fix this problem:
                    string lineString = buffer[row].ToString().Replace( '\0', ' ');

                    GUI.Label(new Rect(0, (row * charHeight), WindowRect.width - 10, charHeight), lineString, terminalLetterSkin.label);
                }

Each text row is drawn at a position 0 pixels from the right edge of the previous bounding box I mentioned, note this 0 is also hardcoded.

There's just no opportunity for another mod to be doing anything to us here.

I suppose that GUI.Label may be drawing the text with a weirdly large left margin in the terminalLetterSkin settings, but again, I don't see how that skin could be changed by anything. It's our skin we create from scratch.

and the place we make that skin has this code, again with hardcoded values:

            theSkin.label.padding = new RectOffset(0, 0, 0, 0);
            theSkin.label.margin = new RectOffset(1, 1, 1, 1);

In trying to read the code to find any opportunity for this stuff to be getting changed, I'm coming up dry. And I can't run it and debug it to find out since it doesn't happen on my computer, only on yours.

elishaday54 commented 6 years ago

Hmm, yeah I honestly have no clue why. I just got a new laptop so I'll see if a similar install will cause the same issue.

elishaday54 commented 6 years ago

Okay, so far testing has revealed the kOS terminal looks how it should on a ksp 1.2.2 install with ONLY kOS installed. Therefore, we can assume something else is stuffing it up and I'm going to try and figure out what it is, then let you know.

Dunbaratu commented 6 years ago

The only thing I can think of is if a mod messed with the gui style in some way we inherited.

Dunbaratu commented 6 years ago

As in the text formatting values that alter margins of labels. We should be setting them explicitly but one might leak through and stay as default such that if others altered the default we got that alteration.

elishaday54 commented 6 years ago

Hmm, yeah. You haven't had anything like this in the past?

Dunbaratu commented 6 years ago

Never. It's really confusing.

elishaday54 commented 6 years ago

Huh, well that's weird then

elishaday54 commented 6 years ago

Okay so things get even weirder now... I had kOS and MechJeb installed, kOS works fine...so I install RO and RSS...kOS breaks. Uninstall everything except for kOS...works fine Reinstall everything else...kOS is fine... So um, idek?

Could be a situation of "install kOS and run KSP first, then install whatever else you want"?

Dunbaratu commented 6 years ago

Given that it changes by de-installing and re-installing the same mods in a different order - I wonder if there's something in the order that KSP loads the mods in that isn't quite alphabetical. Maybe it just loads the mods in whatever "raw order" they appear in a directory reading without sortation. Then it could be possible that when kOS loads before (whichever mod is doing this), it's fine, but when kOS loads after (whichever mod is doing this) it's not.

iliketomovit commented 5 years ago

Hello, I have this issue described by @Elisha-Day in my modded KSP 1.3.1 and later in 1.4.1. I am using github version of kOS 1.1.5.2. The faulty behavior and screenshots are identical for me. I have just done a mod collision test (adding mods in small groups and loading the game).

The issue dissapeared when Real Time Clock v1.9.0.0 was removed. @Elisha-Day I can see it in your mod list. You can try it. So I am happy now. Thank you for developing kOS.

Good luck

BobKermanIndustries commented 1 year ago

Same issue here, the cursor moves form the full left while the text is put to the side by 3 charecters so it is offiset by 3 chrecters to the left, but I don't have Real Time Clock so I don't know. image