Skin, ModernSkin, Machichara setting implemented

main
Inga 🏳‍🌈 13 years ago
parent 62efe0628f
commit 81542f0b65
  1. 2
      Builder/IISMainHandler/build.txt
  2. 7
      Common/Config.cs
  3. 7
      Common/dataobjects/AnonymousUserSettings.cs
  4. 18
      Common/dataobjects/Machichara.cs
  5. 18
      Common/dataobjects/ModernSkin.cs
  6. 18
      Common/dataobjects/Skin.cs

@ -45,6 +45,10 @@ namespace FLocal.Common {
public readonly int SessionLifetime;
public readonly string DefaultModernSkin;
public readonly string DefaultLegacySkin;
public readonly string DefaultMachichara;
protected Config(NameValueCollection data) : base(data) {
this.InitTime = DateTime.Now.ToLongTimeString();
this.mainConnection = new MySQLConnector.Connection(data["ConnectionString"], MySQLConnector.PostgresDBTraits.instance);
@ -64,6 +68,9 @@ namespace FLocal.Common {
this.forceHttps = parseBool(data["ForceHTTPS"]);
this.MinPostId = int.Parse(data["MinPostId"]);
this.SessionLifetime = int.Parse(data["SessionLifetime"]);
this.DefaultLegacySkin = data["DefaultLegacySkin"];
this.DefaultModernSkin = data["DefaultModernSkin"];
this.DefaultMachichara = data["DefaultMachichara"];
}
public static void Init(NameValueCollection data) {

@ -13,9 +13,10 @@ namespace FLocal.Common.dataobjects {
this.account = account;
//var allSkins = Skin.allSkins.ToArray();
//this._skinId = allSkins[Util.RandomInt(0, allSkins.Length)].id;
this._skinId = 28;
this._modernSkinId = 2;
this._machicharaId = 5;
//this._skinId = 28;
this._skinId = Skin.LoadByName(Config.instance.DefaultLegacySkin).id;
this._modernSkinId = ModernSkin.LoadByName(Config.instance.DefaultModernSkin).id;
this._machicharaId = Machichara.LoadByName(Config.instance.DefaultMachichara).id;
}
public int threadsPerPage {

@ -66,5 +66,23 @@ namespace FLocal.Common.dataobjects {
);
}
private static Dictionary<string, int> name2id = new Dictionary<string, int>();
public static Machichara LoadByName(string _name) {
string name = _name;
if(!name2id.ContainsKey(name)) {
lock(name2id) {
if(!name2id.ContainsKey(name)) {
name2id[name] = int.Parse(
Config.instance.mainConnection.LoadIdByField(
TableSpec.instance.getColumnSpec(TableSpec.FIELD_NAME),
name
)
);
}
}
}
return Machichara.LoadById(name2id[name]);
}
}
}

@ -66,5 +66,23 @@ namespace FLocal.Common.dataobjects {
);
}
private static Dictionary<string, int> name2id = new Dictionary<string, int>();
public static ModernSkin LoadByName(string _name) {
string name = _name;
if(!name2id.ContainsKey(name)) {
lock(name2id) {
if(!name2id.ContainsKey(name)) {
name2id[name] = int.Parse(
Config.instance.mainConnection.LoadIdByField(
TableSpec.instance.getColumnSpec(TableSpec.FIELD_NAME),
name
)
);
}
}
}
return ModernSkin.LoadById(name2id[name]);
}
}
}

@ -66,5 +66,23 @@ namespace FLocal.Common.dataobjects {
);
}
private static Dictionary<string, int> name2id = new Dictionary<string, int>();
public static Skin LoadByName(string _name) {
string name = _name;
if(!name2id.ContainsKey(name)) {
lock(name2id) {
if(!name2id.ContainsKey(name)) {
name2id[name] = int.Parse(
Config.instance.mainConnection.LoadIdByField(
TableSpec.instance.getColumnSpec(TableSpec.FIELD_NAME),
name
)
);
}
}
}
return Skin.LoadById(name2id[name]);
}
}
}

Loading…
Cancel
Save