private int SortModList(ComboModInfo a, ComboModInfo b) { int statusOrderA = statusSortOrder[(int)a.networkStatus]; int statusOrderB = statusSortOrder[(int)b.networkStatus]; if (statusOrderA == statusOrderB) { return(string.Compare(a.displayName, b.displayName)); } else { return(statusOrderA - statusOrderB); } }
private void RefreshOtherPlayerPick() { ComboModInfo foundMod = null; if (otherPlayerPickModName != null) { for (int i = 0; i < allMods.Count; i++) { ComboModInfo mod = allMods[i]; if (mod.modName == otherPlayerPickModName) { foundMod = mod; break; } } } if (screen.State == (int)LobbyScreen.HostGamePrefs) { if (foundMod == null) { pickedModBottom.Value = "None"; } else { pickedModBottom.Value = foundMod.displayName; } } else { if (foundMod == null) { pickedModTop.Value = "None selected"; } else { pickedModTop.Value = foundMod.displayName; } } }
private void SetPickedMod(ComboModInfo mod) { pickedMod = mod; if (screen.State == (int)LobbyScreen.HostGamePrefs) { if (pickedMod != null) { pickedModTop.Value = pickedMod.displayName; } else { pickedModTop.Value = "Pick a mod!"; } } else { if (pickedMod != null) { pickedModBottom.Value = pickedMod.displayName; } else { pickedModBottom.Value = "Pick a mod!"; } } SendPickedModOverNetwork(); if (mod == null || mod.networkStatus != ModNetworkStatus.Playable) { selectedModName.Value = null; } else { selectedModName.Value = mod.filePath; } BalugaDebug.Log("Mod picked: " + (mod == null ? "none" : mod.modName + " " + mod.networkStatus)); }
private void PopulateModList() { bool isHost = localInfo.IsHost; modButtons.Buttons.Clear(); for (int i = 0; i < allMods.Count; i++) { ComboModInfo mod = allMods[i]; ModListButton btn = new ModListButton(); btn.NameString = string.Format("{0} v{1} by {2}", mod.displayName, mod.displayVersion, mod.author); switch (mod.networkStatus) { case ModNetworkStatus.Unknown: btn.StatusString = ""; break; case ModNetworkStatus.Playable: btn.StatusString = "Playable!"; break; case ModNetworkStatus.HostOutOfDate: if (isHost) { btn.StatusString = "Out of date"; } else { btn.StatusString = "Friend's out of date"; } break; case ModNetworkStatus.ClientOutOfDate: if (!isHost) { btn.StatusString = "Out of date"; } else { btn.StatusString = "Friend's out of date"; } break; case ModNetworkStatus.OnlyHost: if (isHost) { btn.StatusString = "Friend does not have"; } else { btn.StatusString = "Friend's only"; } break; case ModNetworkStatus.OnlyClient: if (!isHost) { btn.StatusString = "Friend does not have"; } else { btn.StatusString = "Friend's only"; } break; } btn.Order = i; btn.Choosable = !readyStatus.Value; modButtons.Buttons.Add(btn); } modButtons.OnListUpdate.Send(); }
private void CombineLocalAndNetworkMods() { Dictionary <string, int> nameMap = new Dictionary <string, int>(); allMods.Clear(); ModNetworkStatus onlyMe = localInfo.IsHost ? ModNetworkStatus.OnlyHost : ModNetworkStatus.OnlyClient; ModNetworkStatus onlyOther = localInfo.IsHost ? ModNetworkStatus.OnlyClient : ModNetworkStatus.OnlyHost; for (int i = 0; i < networkMods.Count; i++) { NetworkModInfo mod = networkMods[i]; if (showNotLocalMods || mod.networkStatus != onlyOther) { allMods.Add(new ComboModInfo() { filePath = null, modName = mod.modName, numericVersion = mod.numericVersion, displayName = mod.displayName, displayVersion = mod.displayVersion, author = mod.author, networkStatus = mod.networkStatus, }); nameMap[mod.modName] = allMods.Count - 1; } } for (int i = 0; i < localMods.Count; i++) { LocalModInfo local = localMods[i]; int index = 0; ComboModInfo mod; if (nameMap.TryGetValue(local.modName, out index)) { mod = allMods[index]; if (mod.numericVersion <= local.numericVersion) { mod.numericVersion = local.numericVersion; mod.displayName = local.displayName; mod.displayVersion = local.displayVersion; mod.author = local.author; } } else { mod = new ComboModInfo() { modName = local.modName, numericVersion = local.numericVersion, displayName = local.displayName, displayVersion = local.displayVersion, author = local.author, networkStatus = onlyMe, }; allMods.Add(mod); } mod.filePath = local.filePath; } allMods.Sort(SortModList); if (pickedMod != null) { bool pickedNotModFound = true; for (int i = 0; i < allMods.Count; i++) { ComboModInfo mod = allMods[i]; if (mod.modName == pickedMod.modName) { pickedNotModFound = false; SetPickedMod(mod); break; } } if (pickedNotModFound) { SetPickedMod(null); } } Unity.GameLink.NetMods = allMods; RefreshOtherPlayerPick(); }