示例#1
0
        public static bool RemoveUserShow(UserShowDef userShow)
        {
            // Remove from settings
            RimFlixSettings settings = LoadedModManager.GetMod <RimFlixMod>().GetSettings <RimFlixSettings>();

            if (!settings.UserShows.Contains(userShow))
            {
                Log.Message($"RimFlix: Could not find show {userShow.defName} : {userShow.label}");
                return(false);
            }
            bool result = settings.UserShows.Remove(userShow);

            // We can't delete from DefDatabase, so mark as deleted
            userShow.deleted = true;

            // Do not remove graphic data if there are other shows with same path
            IEnumerable <UserShowDef> twins = DefDatabase <UserShowDef> .AllDefs.Where(s => (s.path?.Equals(userShow.path) ?? false) && !s.deleted);

            if (!twins.Any())
            {
                foreach (GraphicData frame in userShow.frames)
                {
                    result = RimFlixContent.contentList.Remove(frame.texPath);
                }
            }
            RimFlixSettings.showUpdateTime = RimFlixSettings.TotalSeconds;
            return(true);
        }
示例#2
0
        public static void ResolveDisabledShows()
        {
            RimFlixSettings       settings = LoadedModManager.GetMod <RimFlixMod>().GetSettings <RimFlixSettings>();
            IEnumerable <ShowDef> shows    = DefDatabase <ShowDef> .AllDefs;

            foreach (ShowDef show in shows)
            {
                show.disabled = settings.DisabledShows == null ? false : settings.DisabledShows.Contains(show.defName);
            }
        }
示例#3
0
        public override void Initialize(CompProperties props)
        {
            base.Initialize(props);

            this.settings         = LoadedModManager.GetMod <RimFlixMod>().GetSettings <RimFlixSettings>();
            this.compPowerTrader  = this.parent.GetComp <CompPowerTrader>();
            this.powerOutputOn    = -1f * this.compPowerTrader.Props.basePowerConsumption * this.settings.PowerConsumptionOn / 100f;
            this.powerOutputOff   = -1f * this.compPowerTrader.Props.basePowerConsumption * this.settings.PowerConsumptionOff / 100f;
            this.screenUpdateTime = 0;
            this.showUpdateTime   = 0;
        }
示例#4
0
        public Dialog_Preview(string path, string name)
        {
            this.doCloseX                = true;
            this.doCloseButton           = true;
            this.forcePause              = true;
            this.absorbInputAroundWindow = true;

            this.path     = path;
            this.name     = name;
            this.frameTex = LoadPNG(this.path);

            this.tubeTex = ThingDef.Named("TubeTelevision").graphic.MatSouth.mainTexture;
            this.flatTex = ThingDef.Named("FlatscreenTelevision").graphic.MatSouth.mainTexture;
            this.megaTex = ThingDef.Named("MegascreenTelevision").graphic.MatSouth.mainTexture;

            this.tubeVec = ThingDef.Named("TubeTelevision").graphicData.drawSize;
            this.flatVec = ThingDef.Named("FlatscreenTelevision").graphicData.drawSize;
            this.megaVec = ThingDef.Named("MegascreenTelevision").graphicData.drawSize;

            this.settings = LoadedModManager.GetMod <RimFlixMod>().GetSettings <RimFlixSettings>();
        }
示例#5
0
        public static void LoadUserShowDefs()
        {
            RimFlixSettings    settings     = LoadedModManager.GetMod <RimFlixMod>().GetSettings <RimFlixSettings>();
            List <UserShowDef> invalidShows = new List <UserShowDef>();
            int count = 0;

            foreach (UserShowDef userShow in settings.UserShows)
            {
                if (LoadUserShow(userShow))
                {
                    count++;
                }
                else
                {
                    invalidShows.Add(userShow);
                    Log.Message($"Removed {userShow.defName} : {userShow.label} from list.");
                }
            }
            if (count != settings.UserShows.Count)
            {
                Log.Message($"RimFlix: {count} out of {settings.UserShows.Count} UserShowDefs loaded.");
            }
            settings.UserShows.RemoveAll(show => invalidShows.Contains(show));
        }
示例#6
0
        public Dialog_AddShow(UserShowDef userShow = null, RimFlixMod mod = null)
        {
            // Window properties
            this.doCloseX                = true;
            this.doCloseButton           = false;
            this.forcePause              = true;
            this.absorbInputAroundWindow = true;

            // Initialize object
            this.settings   = LoadedModManager.GetMod <RimFlixMod>().GetSettings <RimFlixSettings>();
            this.refreshTex = ContentFinder <Texture2D> .Get("UI/Buttons/Refresh", true);

            Vector2 v1 = Text.CalcSize("RimFlix_TimeSeconds".Translate());
            Vector2 v2 = Text.CalcSize("RimFlix_TimeTicks".Translate());

            this.timeUnitWidth  = Math.Max(v1.x, v2.x) + this.padding * 2;
            this.timeInputWidth = this.optionsWidth - this.timeUnitWidth - this.padding * 2;
            this.timeUnitMenu   = new List <FloatMenuOption>
            {
                new FloatMenuOption("RimFlix_TimeSeconds".Translate(), delegate { this.timeUnit = TimeUnit.Second; }),
                new FloatMenuOption("RimFlix_TimeTicks".Translate(), delegate { this.timeUnit = TimeUnit.Tick; })
            };
            this.timeUnitLabels = new string[]
            {
                "RimFlix_TimeSeconds".Translate(),
                "RimFlix_TimeTicks".Translate()
            };
            string s = new string(Path.GetInvalidFileNameChars());

            this.pathValidator = new Regex(string.Format("[^{0}]*", Regex.Escape(s)));
            try
            {
                this.drives = Directory.GetLogicalDrives();
            }
            catch (Exception ex)
            {
                Log.Message($"RimFlix: Exception for GetLogicalDrives():\n{ex}");
                this.filesWidth += this.drivesWidth;
                this.drivesWidth = 0;
            }

            // Show properties
            if (userShow != null)
            {
                this.showName    = userShow.label;
                this.currentPath = userShow.path;
                this.timeValue   = userShow.secondsBetweenFrames;
                this.playTube    = userShow.televisionDefStrings.Contains("TubeTelevision");
                this.playFlat    = userShow.televisionDefStrings.Contains("FlatscreenTelevision");
                this.playMega    = userShow.televisionDefStrings.Contains("MegascreenTelevision");
            }
            else
            {
                this.showName    = "RimFlix_DefaultName".Translate();
                this.currentPath = Directory.Exists(this.settings.lastPath) ? this.settings.lastPath : this.settings.defaultPath;
                this.timeValue   = 10;
                this.playTube    = false;
                this.playFlat    = false;
                this.playMega    = false;
            }
            this.currentUserShow = userShow;
            this.mod             = mod;
        }
示例#7
0
 public RimFlixMod(ModContentPack content) : base(content)
 {
     this.settings = base.GetSettings <RimFlixSettings>();
 }