mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: slugs back in tanks
This commit is contained in:
1 parent
ba36c600c4
commit
16b3a59f88
7 files changed
+91
-98
No files matched your search
@@ -6,6 +6,5 @@ package blitzkit;
|
||||
|
||||
message Tank {
|
||||
required string id = 1;
|
||||
required string slug = 2;
|
||||
required I18n name = 3;
|
||||
required I18n name = 2;
|
||||
}
|
||||
@@ -12,12 +12,11 @@ export const protobufPackage = "blitzkit";
|
||||
|
||||
export interface Tank {
|
||||
id: string;
|
||||
slug: string;
|
||||
name: I18n;
|
||||
}
|
||||
|
||||
function createBaseTank(): Tank {
|
||||
return { id: "", slug: "", name: createBaseI18n() };
|
||||
return { id: "", name: createBaseI18n() };
|
||||
}
|
||||
|
||||
export const Tank: MessageFns<Tank> = {
|
||||
@@ -25,11 +24,8 @@ export const Tank: MessageFns<Tank> = {
|
||||
if (message.id !== "") {
|
||||
writer.uint32(10).string(message.id);
|
||||
}
|
||||
if (message.slug !== "") {
|
||||
writer.uint32(18).string(message.slug);
|
||||
}
|
||||
if (message.name !== undefined) {
|
||||
I18n.encode(message.name, writer.uint32(26).fork()).join();
|
||||
I18n.encode(message.name, writer.uint32(18).fork()).join();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
@@ -54,14 +50,6 @@ export const Tank: MessageFns<Tank> = {
|
||||
break;
|
||||
}
|
||||
|
||||
message.slug = reader.string();
|
||||
continue;
|
||||
}
|
||||
case 3: {
|
||||
if (tag !== 26) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.name = I18n.decode(reader, reader.uint32());
|
||||
continue;
|
||||
}
|
||||
@@ -77,7 +65,6 @@ export const Tank: MessageFns<Tank> = {
|
||||
fromJSON(object: any): Tank {
|
||||
return {
|
||||
id: globalThis.String(assertSet("Tank.id", object.id)),
|
||||
slug: globalThis.String(assertSet("Tank.slug", object.slug)),
|
||||
name: I18n.fromJSON(assertSet("Tank.name", object.name)),
|
||||
};
|
||||
},
|
||||
@@ -87,9 +74,6 @@ export const Tank: MessageFns<Tank> = {
|
||||
if (message.id !== "") {
|
||||
obj.id = message.id;
|
||||
}
|
||||
if (message.slug !== "") {
|
||||
obj.slug = message.slug;
|
||||
}
|
||||
if (message.name !== undefined) {
|
||||
obj.name = I18n.toJSON(message.name);
|
||||
}
|
||||
@@ -102,7 +86,6 @@ export const Tank: MessageFns<Tank> = {
|
||||
fromPartial<I extends Exact<DeepPartial<Tank>, I>>(object: I): Tank {
|
||||
const message = createBaseTank();
|
||||
message.id = object.id ?? "";
|
||||
message.slug = object.slug ?? "";
|
||||
message.name = (object.name !== undefined && object.name !== null)
|
||||
? I18n.fromPartial(object.name)
|
||||
: createBaseI18n();
|
||||
|
||||
@@ -8,4 +8,5 @@ message Tanks {
|
||||
|
||||
message TankMeta {
|
||||
required string id = 1;
|
||||
required string slug = 2;
|
||||
}
|
||||
@@ -15,6 +15,7 @@ export interface Tanks {
|
||||
|
||||
export interface TankMeta {
|
||||
id: string;
|
||||
slug: string;
|
||||
}
|
||||
|
||||
function createBaseTanks(): Tanks {
|
||||
@@ -76,7 +77,7 @@ export const Tanks: MessageFns<Tanks> = {
|
||||
};
|
||||
|
||||
function createBaseTankMeta(): TankMeta {
|
||||
return { id: "" };
|
||||
return { id: "", slug: "" };
|
||||
}
|
||||
|
||||
export const TankMeta: MessageFns<TankMeta> = {
|
||||
@@ -84,6 +85,9 @@ export const TankMeta: MessageFns<TankMeta> = {
|
||||
if (message.id !== "") {
|
||||
writer.uint32(10).string(message.id);
|
||||
}
|
||||
if (message.slug !== "") {
|
||||
writer.uint32(18).string(message.slug);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
@@ -102,6 +106,14 @@ export const TankMeta: MessageFns<TankMeta> = {
|
||||
message.id = reader.string();
|
||||
continue;
|
||||
}
|
||||
case 2: {
|
||||
if (tag !== 18) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.slug = reader.string();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((tag & 7) === 4 || tag === 0) {
|
||||
break;
|
||||
@@ -112,7 +124,10 @@ export const TankMeta: MessageFns<TankMeta> = {
|
||||
},
|
||||
|
||||
fromJSON(object: any): TankMeta {
|
||||
return { id: globalThis.String(assertSet("TankMeta.id", object.id)) };
|
||||
return {
|
||||
id: globalThis.String(assertSet("TankMeta.id", object.id)),
|
||||
slug: globalThis.String(assertSet("TankMeta.slug", object.slug)),
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: TankMeta): unknown {
|
||||
@@ -120,6 +135,9 @@ export const TankMeta: MessageFns<TankMeta> = {
|
||||
if (message.id !== "") {
|
||||
obj.id = message.id;
|
||||
}
|
||||
if (message.slug !== "") {
|
||||
obj.slug = message.slug;
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
@@ -129,6 +147,7 @@ export const TankMeta: MessageFns<TankMeta> = {
|
||||
fromPartial<I extends Exact<DeepPartial<TankMeta>, I>>(object: I): TankMeta {
|
||||
const message = createBaseTankMeta();
|
||||
message.id = object.id ?? "";
|
||||
message.slug = object.slug ?? "";
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -110,7 +110,12 @@ namespace BlitzKit.CLI.Functions
|
||||
|
||||
var tank = MangleTank(tankDir.Value);
|
||||
|
||||
TankMeta tankMeta = new() { Id = tank.Id };
|
||||
var slug = Diacritics.Remove(tank.Name.Locales["en"]).ToLower();
|
||||
slug = Regex.Replace(slug, "[^a-z0-9]", "-");
|
||||
slug = Regex.Replace(slug, "--+", "-");
|
||||
slug = Regex.Replace(slug, "-$", "");
|
||||
|
||||
TankMeta tankMeta = new() { Id = tank.Id, Slug = slug };
|
||||
|
||||
tanks.Tanks_.Add(tankMeta);
|
||||
}
|
||||
@@ -124,24 +129,11 @@ namespace BlitzKit.CLI.Functions
|
||||
var pda = provider.LoadObject($"{tankDir.Path}/{pdaName}.{pdaName}");
|
||||
|
||||
var id = PropertyUtil.Get<FName>(pda, "TankId").Text;
|
||||
|
||||
var name = GetString($"{id}_SHORT_NAME");
|
||||
|
||||
var slug = Diacritics.Remove(name.Locales["en"]).ToLower();
|
||||
slug = Regex.Replace(slug, "[^a-z0-9]", "-");
|
||||
slug = Regex.Replace(slug, "--+", "-");
|
||||
slug = Regex.Replace(slug, "-$", "");
|
||||
|
||||
// MangleHull(id, pda);
|
||||
|
||||
Console.WriteLine(slug);
|
||||
|
||||
Tank tank = new()
|
||||
{
|
||||
Id = id,
|
||||
Name = name,
|
||||
Slug = slug,
|
||||
};
|
||||
Tank tank = new() { Id = id, Name = name };
|
||||
|
||||
changes.Add(new($"definitions/tanks/{id}.pb", tank.ToByteArray()));
|
||||
|
||||
|
||||
@@ -25,13 +25,12 @@ namespace Blitzkit {
|
||||
byte[] descriptorData = global::System.Convert.FromBase64String(
|
||||
string.Concat(
|
||||
"CiNwYWNrYWdlcy9jb3JlL3NyYy9wcm90b3MvdGFuay5wcm90bxIIYmxpdHpr",
|
||||
"aXQaI3BhY2thZ2VzL2NvcmUvc3JjL3Byb3Rvcy9pMThuLnByb3RvIj4KBFRh",
|
||||
"bmsSCgoCaWQYASACKAkSDAoEc2x1ZxgCIAIoCRIcCgRuYW1lGAMgAigLMg4u",
|
||||
"YmxpdHpraXQuSTE4bg=="));
|
||||
"aXQaI3BhY2thZ2VzL2NvcmUvc3JjL3Byb3Rvcy9pMThuLnByb3RvIjAKBFRh",
|
||||
"bmsSCgoCaWQYASACKAkSHAoEbmFtZRgCIAIoCzIOLmJsaXR6a2l0LkkxOG4="));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { global::Blitzkit.I18NReflection.Descriptor, },
|
||||
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Blitzkit.Tank), global::Blitzkit.Tank.Parser, new[]{ "Id", "Slug", "Name" }, null, null, null, null)
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Blitzkit.Tank), global::Blitzkit.Tank.Parser, new[]{ "Id", "Name" }, null, null, null, null)
|
||||
}));
|
||||
}
|
||||
#endregion
|
||||
@@ -74,7 +73,6 @@ namespace Blitzkit {
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public Tank(Tank other) : this() {
|
||||
id_ = other.id_;
|
||||
slug_ = other.slug_;
|
||||
name_ = other.name_ != null ? other.name_.Clone() : null;
|
||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||
}
|
||||
@@ -111,34 +109,8 @@ namespace Blitzkit {
|
||||
id_ = null;
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "slug" field.</summary>
|
||||
public const int SlugFieldNumber = 2;
|
||||
private readonly static string SlugDefaultValue = "";
|
||||
|
||||
private string slug_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public string Slug {
|
||||
get { return slug_ ?? SlugDefaultValue; }
|
||||
set {
|
||||
slug_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
/// <summary>Gets whether the "slug" field is set</summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public bool HasSlug {
|
||||
get { return slug_ != null; }
|
||||
}
|
||||
/// <summary>Clears the value of the "slug" field</summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void ClearSlug() {
|
||||
slug_ = null;
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "name" field.</summary>
|
||||
public const int NameFieldNumber = 3;
|
||||
public const int NameFieldNumber = 2;
|
||||
private global::Blitzkit.I18n name_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
@@ -165,7 +137,6 @@ namespace Blitzkit {
|
||||
return true;
|
||||
}
|
||||
if (Id != other.Id) return false;
|
||||
if (Slug != other.Slug) return false;
|
||||
if (!object.Equals(Name, other.Name)) return false;
|
||||
return Equals(_unknownFields, other._unknownFields);
|
||||
}
|
||||
@@ -175,7 +146,6 @@ namespace Blitzkit {
|
||||
public override int GetHashCode() {
|
||||
int hash = 1;
|
||||
if (HasId) hash ^= Id.GetHashCode();
|
||||
if (HasSlug) hash ^= Slug.GetHashCode();
|
||||
if (name_ != null) hash ^= Name.GetHashCode();
|
||||
if (_unknownFields != null) {
|
||||
hash ^= _unknownFields.GetHashCode();
|
||||
@@ -199,12 +169,8 @@ namespace Blitzkit {
|
||||
output.WriteRawTag(10);
|
||||
output.WriteString(Id);
|
||||
}
|
||||
if (HasSlug) {
|
||||
output.WriteRawTag(18);
|
||||
output.WriteString(Slug);
|
||||
}
|
||||
if (name_ != null) {
|
||||
output.WriteRawTag(26);
|
||||
output.WriteRawTag(18);
|
||||
output.WriteMessage(Name);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
@@ -221,12 +187,8 @@ namespace Blitzkit {
|
||||
output.WriteRawTag(10);
|
||||
output.WriteString(Id);
|
||||
}
|
||||
if (HasSlug) {
|
||||
output.WriteRawTag(18);
|
||||
output.WriteString(Slug);
|
||||
}
|
||||
if (name_ != null) {
|
||||
output.WriteRawTag(26);
|
||||
output.WriteRawTag(18);
|
||||
output.WriteMessage(Name);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
@@ -242,9 +204,6 @@ namespace Blitzkit {
|
||||
if (HasId) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(Id);
|
||||
}
|
||||
if (HasSlug) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(Slug);
|
||||
}
|
||||
if (name_ != null) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeMessageSize(Name);
|
||||
}
|
||||
@@ -263,9 +222,6 @@ namespace Blitzkit {
|
||||
if (other.HasId) {
|
||||
Id = other.Id;
|
||||
}
|
||||
if (other.HasSlug) {
|
||||
Slug = other.Slug;
|
||||
}
|
||||
if (other.name_ != null) {
|
||||
if (name_ == null) {
|
||||
Name = new global::Blitzkit.I18n();
|
||||
@@ -296,10 +252,6 @@ namespace Blitzkit {
|
||||
break;
|
||||
}
|
||||
case 18: {
|
||||
Slug = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 26: {
|
||||
if (name_ == null) {
|
||||
Name = new global::Blitzkit.I18n();
|
||||
}
|
||||
@@ -330,10 +282,6 @@ namespace Blitzkit {
|
||||
break;
|
||||
}
|
||||
case 18: {
|
||||
Slug = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 26: {
|
||||
if (name_ == null) {
|
||||
Name = new global::Blitzkit.I18n();
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ namespace Blitzkit {
|
||||
string.Concat(
|
||||
"CiRwYWNrYWdlcy9jb3JlL3NyYy9wcm90b3MvdGFua3MucHJvdG8SCGJsaXR6",
|
||||
"a2l0IioKBVRhbmtzEiEKBXRhbmtzGAEgAygLMhIuYmxpdHpraXQuVGFua01l",
|
||||
"dGEiFgoIVGFua01ldGESCgoCaWQYASACKAk="));
|
||||
"dGEiJAoIVGFua01ldGESCgoCaWQYASACKAkSDAoEc2x1ZxgCIAIoCQ=="));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { },
|
||||
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Blitzkit.Tanks), global::Blitzkit.Tanks.Parser, new[]{ "Tanks_" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Blitzkit.TankMeta), global::Blitzkit.TankMeta.Parser, new[]{ "Id" }, null, null, null, null)
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Blitzkit.TankMeta), global::Blitzkit.TankMeta.Parser, new[]{ "Id", "Slug" }, null, null, null, null)
|
||||
}));
|
||||
}
|
||||
#endregion
|
||||
@@ -261,6 +261,7 @@ namespace Blitzkit {
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public TankMeta(TankMeta other) : this() {
|
||||
id_ = other.id_;
|
||||
slug_ = other.slug_;
|
||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||
}
|
||||
|
||||
@@ -296,6 +297,32 @@ namespace Blitzkit {
|
||||
id_ = null;
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "slug" field.</summary>
|
||||
public const int SlugFieldNumber = 2;
|
||||
private readonly static string SlugDefaultValue = "";
|
||||
|
||||
private string slug_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public string Slug {
|
||||
get { return slug_ ?? SlugDefaultValue; }
|
||||
set {
|
||||
slug_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
/// <summary>Gets whether the "slug" field is set</summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public bool HasSlug {
|
||||
get { return slug_ != null; }
|
||||
}
|
||||
/// <summary>Clears the value of the "slug" field</summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void ClearSlug() {
|
||||
slug_ = null;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override bool Equals(object other) {
|
||||
@@ -312,6 +339,7 @@ namespace Blitzkit {
|
||||
return true;
|
||||
}
|
||||
if (Id != other.Id) return false;
|
||||
if (Slug != other.Slug) return false;
|
||||
return Equals(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
@@ -320,6 +348,7 @@ namespace Blitzkit {
|
||||
public override int GetHashCode() {
|
||||
int hash = 1;
|
||||
if (HasId) hash ^= Id.GetHashCode();
|
||||
if (HasSlug) hash ^= Slug.GetHashCode();
|
||||
if (_unknownFields != null) {
|
||||
hash ^= _unknownFields.GetHashCode();
|
||||
}
|
||||
@@ -342,6 +371,10 @@ namespace Blitzkit {
|
||||
output.WriteRawTag(10);
|
||||
output.WriteString(Id);
|
||||
}
|
||||
if (HasSlug) {
|
||||
output.WriteRawTag(18);
|
||||
output.WriteString(Slug);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(output);
|
||||
}
|
||||
@@ -356,6 +389,10 @@ namespace Blitzkit {
|
||||
output.WriteRawTag(10);
|
||||
output.WriteString(Id);
|
||||
}
|
||||
if (HasSlug) {
|
||||
output.WriteRawTag(18);
|
||||
output.WriteString(Slug);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(ref output);
|
||||
}
|
||||
@@ -369,6 +406,9 @@ namespace Blitzkit {
|
||||
if (HasId) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(Id);
|
||||
}
|
||||
if (HasSlug) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(Slug);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
size += _unknownFields.CalculateSize();
|
||||
}
|
||||
@@ -384,6 +424,9 @@ namespace Blitzkit {
|
||||
if (other.HasId) {
|
||||
Id = other.Id;
|
||||
}
|
||||
if (other.HasSlug) {
|
||||
Slug = other.Slug;
|
||||
}
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
@@ -407,6 +450,10 @@ namespace Blitzkit {
|
||||
Id = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 18: {
|
||||
Slug = input.ReadString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -430,6 +477,10 @@ namespace Blitzkit {
|
||||
Id = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 18: {
|
||||
Slug = input.ReadString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user