Esempio n. 1
0
            public void CustomControlGetter(IMyTerminalBlock block, List <IMyTerminalControl> controls)
            {
                if (!(block is IMyProjector))
                {
                    return;
                }

                Projector instance;

                if (!Registrar.TryGetValue(block, out instance))
                {
                    if (!Globals.WorldClosed)
                    {
                        Logger.AlwaysLog("Failed to get block: " + block.nameWithId());
                    }
                    return;
                }

                controls.Add(TermControls[0]);
                controls.Add(TermControls[1]);

                if (instance.GetOption(Option.OnOff))
                {
                    // find show on hud
                    int indexSOH = 0;
                    for (; indexSOH < controls.Count && controls[indexSOH].Id != "ShowOnHUD"; indexSOH++)
                    {
                        ;
                    }
                    // remove all controls after ShowOnHUD and before separator
                    controls.RemoveRange(indexSOH + 1, controls.Count - indexSOH - 3);

                    bool showOffset = ShowOffset;

                    for (int index = 2; index < TermControls.Count; index++)
                    {
                        controls.Add(TermControls[index]);
                        if (showOffset && TermControls[index].Id == "HD_ShowOffset")
                        {
                            showOffset = false;
                            foreach (var offset in TermControls_Offset)
                            {
                                controls.Add(offset);
                            }
                        }
                    }

                    if (instance.GetOption(Option.IntegrityColours))
                    {
                        foreach (var colour in TermControls_Colours)
                        {
                            controls.Add(colour);
                        }
                    }
                }
            }
        private StringBuilder TC_Getter(IMyTerminalBlock block)
        {
            EntityVariables vars;

            if (m_active.TryGetValue(block, out vars))
            {
                Logger.DebugLog("active: " + vars.Text, context: block.nameWithId());
                return(new StringBuilder(vars.Text));
            }
            EntityValue <T> ev = TryGetEntityValue(block, false);

            if (ev != null)
            {
                Logger.DebugLog("stored value: " + ev.Value, context: block.nameWithId());
                return(new StringBuilder(ev.Value.ToString()));
            }
            //Logger.DebugLog("new", context: block.nameWithId());
            return(new StringBuilder());
        }