mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
feat: include slugs in both
This commit is contained in:
1 parent
16b3a59f88
commit
2fffd512ac
4 files changed
+94
-16
No files matched your search
@@ -6,5 +6,6 @@ package blitzkit;
|
|||||||
|
|
||||||
message Tank {
|
message Tank {
|
||||||
required string id = 1;
|
required string id = 1;
|
||||||
required I18n name = 2;
|
required string slug = 2;
|
||||||
|
required I18n name = 3;
|
||||||
}
|
}
|
||||||
@@ -12,11 +12,12 @@ export const protobufPackage = "blitzkit";
|
|||||||
|
|
||||||
export interface Tank {
|
export interface Tank {
|
||||||
id: string;
|
id: string;
|
||||||
|
slug: string;
|
||||||
name: I18n;
|
name: I18n;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createBaseTank(): Tank {
|
function createBaseTank(): Tank {
|
||||||
return { id: "", name: createBaseI18n() };
|
return { id: "", slug: "", name: createBaseI18n() };
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Tank: MessageFns<Tank> = {
|
export const Tank: MessageFns<Tank> = {
|
||||||
@@ -24,8 +25,11 @@ export const Tank: MessageFns<Tank> = {
|
|||||||
if (message.id !== "") {
|
if (message.id !== "") {
|
||||||
writer.uint32(10).string(message.id);
|
writer.uint32(10).string(message.id);
|
||||||
}
|
}
|
||||||
|
if (message.slug !== "") {
|
||||||
|
writer.uint32(18).string(message.slug);
|
||||||
|
}
|
||||||
if (message.name !== undefined) {
|
if (message.name !== undefined) {
|
||||||
I18n.encode(message.name, writer.uint32(18).fork()).join();
|
I18n.encode(message.name, writer.uint32(26).fork()).join();
|
||||||
}
|
}
|
||||||
return writer;
|
return writer;
|
||||||
},
|
},
|
||||||
@@ -50,6 +54,14 @@ export const Tank: MessageFns<Tank> = {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message.slug = reader.string();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case 3: {
|
||||||
|
if (tag !== 26) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
message.name = I18n.decode(reader, reader.uint32());
|
message.name = I18n.decode(reader, reader.uint32());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -65,6 +77,7 @@ export const Tank: MessageFns<Tank> = {
|
|||||||
fromJSON(object: any): Tank {
|
fromJSON(object: any): Tank {
|
||||||
return {
|
return {
|
||||||
id: globalThis.String(assertSet("Tank.id", object.id)),
|
id: globalThis.String(assertSet("Tank.id", object.id)),
|
||||||
|
slug: globalThis.String(assertSet("Tank.slug", object.slug)),
|
||||||
name: I18n.fromJSON(assertSet("Tank.name", object.name)),
|
name: I18n.fromJSON(assertSet("Tank.name", object.name)),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -74,6 +87,9 @@ export const Tank: MessageFns<Tank> = {
|
|||||||
if (message.id !== "") {
|
if (message.id !== "") {
|
||||||
obj.id = message.id;
|
obj.id = message.id;
|
||||||
}
|
}
|
||||||
|
if (message.slug !== "") {
|
||||||
|
obj.slug = message.slug;
|
||||||
|
}
|
||||||
if (message.name !== undefined) {
|
if (message.name !== undefined) {
|
||||||
obj.name = I18n.toJSON(message.name);
|
obj.name = I18n.toJSON(message.name);
|
||||||
}
|
}
|
||||||
@@ -86,6 +102,7 @@ export const Tank: MessageFns<Tank> = {
|
|||||||
fromPartial<I extends Exact<DeepPartial<Tank>, I>>(object: I): Tank {
|
fromPartial<I extends Exact<DeepPartial<Tank>, I>>(object: I): Tank {
|
||||||
const message = createBaseTank();
|
const message = createBaseTank();
|
||||||
message.id = object.id ?? "";
|
message.id = object.id ?? "";
|
||||||
|
message.slug = object.slug ?? "";
|
||||||
message.name = (object.name !== undefined && object.name !== null)
|
message.name = (object.name !== undefined && object.name !== null)
|
||||||
? I18n.fromPartial(object.name)
|
? I18n.fromPartial(object.name)
|
||||||
: createBaseI18n();
|
: createBaseI18n();
|
||||||
|
|||||||
@@ -110,12 +110,7 @@ namespace BlitzKit.CLI.Functions
|
|||||||
|
|
||||||
var tank = MangleTank(tankDir.Value);
|
var tank = MangleTank(tankDir.Value);
|
||||||
|
|
||||||
var slug = Diacritics.Remove(tank.Name.Locales["en"]).ToLower();
|
TankMeta tankMeta = new() { Id = tank.Id, Slug = tank.Slug };
|
||||||
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);
|
tanks.Tanks_.Add(tankMeta);
|
||||||
}
|
}
|
||||||
@@ -129,11 +124,24 @@ namespace BlitzKit.CLI.Functions
|
|||||||
var pda = provider.LoadObject($"{tankDir.Path}/{pdaName}.{pdaName}");
|
var pda = provider.LoadObject($"{tankDir.Path}/{pdaName}.{pdaName}");
|
||||||
|
|
||||||
var id = PropertyUtil.Get<FName>(pda, "TankId").Text;
|
var id = PropertyUtil.Get<FName>(pda, "TankId").Text;
|
||||||
|
|
||||||
var name = GetString($"{id}_SHORT_NAME");
|
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);
|
// MangleHull(id, pda);
|
||||||
|
|
||||||
Tank tank = new() { Id = id, Name = name };
|
Console.WriteLine(slug);
|
||||||
|
|
||||||
|
Tank tank = new()
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Name = name,
|
||||||
|
Slug = slug,
|
||||||
|
};
|
||||||
|
|
||||||
changes.Add(new($"definitions/tanks/{id}.pb", tank.ToByteArray()));
|
changes.Add(new($"definitions/tanks/{id}.pb", tank.ToByteArray()));
|
||||||
|
|
||||||
|
|||||||
@@ -25,12 +25,13 @@ namespace Blitzkit {
|
|||||||
byte[] descriptorData = global::System.Convert.FromBase64String(
|
byte[] descriptorData = global::System.Convert.FromBase64String(
|
||||||
string.Concat(
|
string.Concat(
|
||||||
"CiNwYWNrYWdlcy9jb3JlL3NyYy9wcm90b3MvdGFuay5wcm90bxIIYmxpdHpr",
|
"CiNwYWNrYWdlcy9jb3JlL3NyYy9wcm90b3MvdGFuay5wcm90bxIIYmxpdHpr",
|
||||||
"aXQaI3BhY2thZ2VzL2NvcmUvc3JjL3Byb3Rvcy9pMThuLnByb3RvIjAKBFRh",
|
"aXQaI3BhY2thZ2VzL2NvcmUvc3JjL3Byb3Rvcy9pMThuLnByb3RvIj4KBFRh",
|
||||||
"bmsSCgoCaWQYASACKAkSHAoEbmFtZRgCIAIoCzIOLmJsaXR6a2l0LkkxOG4="));
|
"bmsSCgoCaWQYASACKAkSDAoEc2x1ZxgCIAIoCRIcCgRuYW1lGAMgAigLMg4u",
|
||||||
|
"YmxpdHpraXQuSTE4bg=="));
|
||||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||||
new pbr::FileDescriptor[] { global::Blitzkit.I18NReflection.Descriptor, },
|
new pbr::FileDescriptor[] { global::Blitzkit.I18NReflection.Descriptor, },
|
||||||
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
||||||
new pbr::GeneratedClrTypeInfo(typeof(global::Blitzkit.Tank), global::Blitzkit.Tank.Parser, new[]{ "Id", "Name" }, null, null, null, null)
|
new pbr::GeneratedClrTypeInfo(typeof(global::Blitzkit.Tank), global::Blitzkit.Tank.Parser, new[]{ "Id", "Slug", "Name" }, null, null, null, null)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -73,6 +74,7 @@ namespace Blitzkit {
|
|||||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||||
public Tank(Tank other) : this() {
|
public Tank(Tank other) : this() {
|
||||||
id_ = other.id_;
|
id_ = other.id_;
|
||||||
|
slug_ = other.slug_;
|
||||||
name_ = other.name_ != null ? other.name_.Clone() : null;
|
name_ = other.name_ != null ? other.name_.Clone() : null;
|
||||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||||
}
|
}
|
||||||
@@ -109,8 +111,34 @@ namespace Blitzkit {
|
|||||||
id_ = null;
|
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>
|
/// <summary>Field number for the "name" field.</summary>
|
||||||
public const int NameFieldNumber = 2;
|
public const int NameFieldNumber = 3;
|
||||||
private global::Blitzkit.I18n name_;
|
private global::Blitzkit.I18n name_;
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||||
@@ -137,6 +165,7 @@ namespace Blitzkit {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (Id != other.Id) return false;
|
if (Id != other.Id) return false;
|
||||||
|
if (Slug != other.Slug) return false;
|
||||||
if (!object.Equals(Name, other.Name)) return false;
|
if (!object.Equals(Name, other.Name)) return false;
|
||||||
return Equals(_unknownFields, other._unknownFields);
|
return Equals(_unknownFields, other._unknownFields);
|
||||||
}
|
}
|
||||||
@@ -146,6 +175,7 @@ namespace Blitzkit {
|
|||||||
public override int GetHashCode() {
|
public override int GetHashCode() {
|
||||||
int hash = 1;
|
int hash = 1;
|
||||||
if (HasId) hash ^= Id.GetHashCode();
|
if (HasId) hash ^= Id.GetHashCode();
|
||||||
|
if (HasSlug) hash ^= Slug.GetHashCode();
|
||||||
if (name_ != null) hash ^= Name.GetHashCode();
|
if (name_ != null) hash ^= Name.GetHashCode();
|
||||||
if (_unknownFields != null) {
|
if (_unknownFields != null) {
|
||||||
hash ^= _unknownFields.GetHashCode();
|
hash ^= _unknownFields.GetHashCode();
|
||||||
@@ -169,8 +199,12 @@ namespace Blitzkit {
|
|||||||
output.WriteRawTag(10);
|
output.WriteRawTag(10);
|
||||||
output.WriteString(Id);
|
output.WriteString(Id);
|
||||||
}
|
}
|
||||||
if (name_ != null) {
|
if (HasSlug) {
|
||||||
output.WriteRawTag(18);
|
output.WriteRawTag(18);
|
||||||
|
output.WriteString(Slug);
|
||||||
|
}
|
||||||
|
if (name_ != null) {
|
||||||
|
output.WriteRawTag(26);
|
||||||
output.WriteMessage(Name);
|
output.WriteMessage(Name);
|
||||||
}
|
}
|
||||||
if (_unknownFields != null) {
|
if (_unknownFields != null) {
|
||||||
@@ -187,8 +221,12 @@ namespace Blitzkit {
|
|||||||
output.WriteRawTag(10);
|
output.WriteRawTag(10);
|
||||||
output.WriteString(Id);
|
output.WriteString(Id);
|
||||||
}
|
}
|
||||||
if (name_ != null) {
|
if (HasSlug) {
|
||||||
output.WriteRawTag(18);
|
output.WriteRawTag(18);
|
||||||
|
output.WriteString(Slug);
|
||||||
|
}
|
||||||
|
if (name_ != null) {
|
||||||
|
output.WriteRawTag(26);
|
||||||
output.WriteMessage(Name);
|
output.WriteMessage(Name);
|
||||||
}
|
}
|
||||||
if (_unknownFields != null) {
|
if (_unknownFields != null) {
|
||||||
@@ -204,6 +242,9 @@ namespace Blitzkit {
|
|||||||
if (HasId) {
|
if (HasId) {
|
||||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(Id);
|
size += 1 + pb::CodedOutputStream.ComputeStringSize(Id);
|
||||||
}
|
}
|
||||||
|
if (HasSlug) {
|
||||||
|
size += 1 + pb::CodedOutputStream.ComputeStringSize(Slug);
|
||||||
|
}
|
||||||
if (name_ != null) {
|
if (name_ != null) {
|
||||||
size += 1 + pb::CodedOutputStream.ComputeMessageSize(Name);
|
size += 1 + pb::CodedOutputStream.ComputeMessageSize(Name);
|
||||||
}
|
}
|
||||||
@@ -222,6 +263,9 @@ namespace Blitzkit {
|
|||||||
if (other.HasId) {
|
if (other.HasId) {
|
||||||
Id = other.Id;
|
Id = other.Id;
|
||||||
}
|
}
|
||||||
|
if (other.HasSlug) {
|
||||||
|
Slug = other.Slug;
|
||||||
|
}
|
||||||
if (other.name_ != null) {
|
if (other.name_ != null) {
|
||||||
if (name_ == null) {
|
if (name_ == null) {
|
||||||
Name = new global::Blitzkit.I18n();
|
Name = new global::Blitzkit.I18n();
|
||||||
@@ -252,6 +296,10 @@ namespace Blitzkit {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 18: {
|
case 18: {
|
||||||
|
Slug = input.ReadString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 26: {
|
||||||
if (name_ == null) {
|
if (name_ == null) {
|
||||||
Name = new global::Blitzkit.I18n();
|
Name = new global::Blitzkit.I18n();
|
||||||
}
|
}
|
||||||
@@ -282,6 +330,10 @@ namespace Blitzkit {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 18: {
|
case 18: {
|
||||||
|
Slug = input.ReadString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 26: {
|
||||||
if (name_ == null) {
|
if (name_ == null) {
|
||||||
Name = new global::Blitzkit.I18n();
|
Name = new global::Blitzkit.I18n();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user