Commit d97f836d authored by JoyJ's avatar JoyJ

effect creator UI (incomplete)

parent 857ccd03
Pipeline #131 passed with stage
in 51 seconds
......@@ -212,7 +212,6 @@ private void InitializeComponent()
this.effectCreatorToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F3;
this.effectCreatorToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.effectCreatorToolStripMenuItem.Text = "Effect Creator";
this.effectCreatorToolStripMenuItem.Visible = false;
this.effectCreatorToolStripMenuItem.Click += new System.EventHandler(this.effectCreatorToolStripMenuItem_Click);
//
// tb_input
......
......@@ -65,7 +65,7 @@ public static bool CheckVersion(string ver, string oldver)
{
bool hasNew = false;
#if DEBUG
System.Windows.Forms.MessageBox.Show(oldver + "=>" + ver);
System.Windows.Forms.MessageBox.Show(oldver + "=>" + ver);
#endif
string[] vers = ver.Split('.');
string[] oldvers = oldver.Split('.');
......
This diff is collapsed.
using System;
using System.Collections.Generic;
using System.IO;
using WeifenLuo.WinFormsUI.Docking;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DataEditorX
{
public partial class EffectCreatorForm : DockContent
public partial class EffectCreatorForm : Form
{
public EffectCreatorForm()
{
......@@ -17,6 +19,7 @@ class EffectCreatorItem
public string Key;
public string Value;
public string Hint;
public bool IsSelected;
public EffectCreatorItem(string key, string value)
{
......@@ -34,7 +37,7 @@ public override string ToString()
return Value;
}
}
Dictionary<string, List<EffectCreatorItem>> itemDic = new Dictionary<string, List<EffectCreatorItem>>();
readonly Dictionary<string, List<EffectCreatorItem>> itemDic = new Dictionary<string, List<EffectCreatorItem>>();
private void EffectCreatorForm_Load(object sender, EventArgs e)
{
string config = $"data{Path.DirectorySeparatorChar}effect_creator_settings.txt";
......@@ -72,14 +75,193 @@ private void EffectCreatorForm_Load(object sender, EventArgs e)
itemDic[nowType].Add(new EffectCreatorItem(split[0], split[1], split[2]));
}
}
foreach (var item in itemDic["EFFECT_CODES"])
sr.Close();
fs.Close();
listEffectCode.Items.AddRange(itemDic["EFFECT_CODES"].ToArray());
listEffectCode.Items.AddRange(itemDic["EVENT_CODES"].ToArray());
listEffectCategory.Items.AddRange(itemDic["CATEGORY"].ToArray());
listEffectProperty.Items.AddRange(itemDic["EFFECT_PROPERTY"].ToArray());
}
private void btnStart_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
sb.Append(this.ProcessDescription());
sb.Append(this.ProcessSpecialOptions());
sb.Append(this.ProcessEffectType());
sb.Append(this.ProcessEffectCategory());
sb.Append(this.ProcessEffectProperty());
sb.Append(this.ProcessEffectCode());
txtOutput.Text = sb.ToString();
}
private string ProcessEffectProperty()
{
var selected = (from EffectCreatorItem item in listEffectProperty.Items.Cast<EffectCreatorItem>()
where item.IsSelected
select item).ToArray();
if (selected.Length < 1)
{
return "";
}
string property = selected[0].Key;
if (selected.Length > 1)
{
for (int i = 1; i < selected.Length; i++)
{
property += $"+{selected[i].Key}";
}
}
return $"e{numEffectNum.Value}:SetCategory({property})";
}
private string ProcessEffectCategory()
{
var selected = (from EffectCreatorItem item in listEffectCategory.Items.Cast<EffectCreatorItem>()
where item.IsSelected
select item).ToArray();
if (selected.Length < 1)
{
return "";
}
string category = selected[0].Key;
if (selected.Length > 1)
{
for (int i = 1; i < selected.Length; i++)
{
category += $"+{selected[i].Key}";
}
}
return $"e{numEffectNum.Value}:SetCategory({category})";
}
private string ProcessEffectCode()
{
var selected = (from EffectCreatorItem item in listEffectCode.Items.Cast<EffectCreatorItem>()
where item.IsSelected
select item).ToArray();
if (selected.Length < 1)
{
return "";
}
return $"e{numEffectNum.Value}:SetCode({selected[0].Key})";
}
private string ProcessDescription()
{
if (numDescription.Value >= 0)
{
return $"e{numEffectNum.Value}:SetDescription(aux.Stringid({numCardCode.Value},{numDescription.Value}))";
}
return "";
}
private string ProcessEffectType()
{
string effectType = "";
foreach (RadioButton radio in gbEffectType.Controls)
{
if (radio.Name.StartsWith("radioEffectType"))
{
this.AddEffectTypeByCheckRadio(radio, ref effectType);
}
}
foreach (RadioButton radio in gbEffectType2.Controls)
{
if (radio.Name.StartsWith("radioEffectType"))
{
this.AddEffectTypeByCheckRadio(radio, ref effectType);
}
}
return $"e{numEffectNum.Value}:SetType({effectType})";
}
private void AddEffectTypeByCheckRadio(RadioButton radio, ref string effectType)
{
if (radio.Checked)
{
if (effectType != "")
{
effectType += "+";
}
effectType += $"EFFECT_TYPE_{radio.Name.Substring(15).ToUpper()}";
}
}
private string ProcessSpecialOptions()
{
StringBuilder sb = new StringBuilder();
if (checkEnableReviveLimit.Checked)
{
listEffectCode.Items.Add(item);
sb.AppendLine("c:EnableReviveLimit()");
}
foreach (var item in itemDic["EVENT_CODES"])
if (checkRegisterToPlayer.Checked)
{
listEffectCode.Items.Add(item);
sb.AppendLine($"local e{numEffectNum.Value}=Effect.CreateEffect(c)");
}
else
{
sb.AppendLine($"local e{numEffectNum.Value}=Effect.GlobalEffect()");
}
return sb.ToString();
}
private void SearchListBoxWithTextBox(ref CheckedListBox clb, TextBox tb)
{
if (tb.Text == "")
{
return;
}
var selected = (from EffectCreatorItem item in clb.Items.Cast<EffectCreatorItem>()
where item.IsSelected
select item).ToArray();
var searched = (from EffectCreatorItem item in clb.Items.Cast<EffectCreatorItem>()
where item.Value.Contains(tb.Text) && !selected.Contains(item)
select item).ToArray();
var notSearched = (from EffectCreatorItem item in clb.Items.Cast<EffectCreatorItem>()
where !searched.Contains(item) && !selected.Contains(item)
select item).ToArray();
searched = selected.Concat(searched).Concat(notSearched).ToArray();
clb.Items.Clear();
clb.Items.AddRange(searched);
for (int i = 0; i < clb.Items.Count; i++)
{
if ((clb.Items[i] as EffectCreatorItem).IsSelected)
{
clb.SetItemChecked(i, true);
}
}
}
private void txtSearchEffectCode_TextChanged(object sender, EventArgs e)
{
this.SearchListBoxWithTextBox(ref listEffectCode, txtSearchEffectCode);
}
private void listEffectCode_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (e.NewValue == CheckState.Checked)
{
for (int i = 0; i < ((CheckedListBox)sender).Items.Count; i++)
{
if (((CheckedListBox)sender).GetItemChecked(i) && i != e.Index)
{
((CheckedListBox)sender).SetItemChecked(i, false);
(((CheckedListBox)sender).Items[i] as EffectCreatorItem).IsSelected = false;
}
}
}
(listEffectCode.Items[e.Index] as EffectCreatorItem).IsSelected = e.NewValue == CheckState.Checked;
}
private void txtSearchEffectCategory_TextChanged(object sender, EventArgs e)
{
this.SearchListBoxWithTextBox(ref listEffectCategory, txtSearchEffectCategory);
}
private void txtSearchProperty_TextChanged(object sender, EventArgs e)
{
this.SearchListBoxWithTextBox(ref listEffectProperty, txtSearchProperty);
}
}
}
......@@ -313,7 +313,35 @@ EVENT_PHASE 阶段结束时
EVENT_PHASE_START 阶段开始时
EVENT_ADD_COUNTER 增加指示物时
EVENT_REMOVE_COUNTER 去除指示物时 Card.RemoveCounter()必须手动触发此事件
EVENT_CUSTOM 自訂事件
EVENT_CUSTOM 自定义事件
!EFFECT_PROPERTY
EFFECT_FLAG_CARD_TARGET 此效果取对象
EFFECT_FLAG_IGNORE_RANGE 此效果影响任何区域的卡
EFFECT_FLAG_ABSOLUTE_TARGET 此效果的Target Range不会因为控制权的改变而改变
EFFECT_FLAG_IGNORE_IMMUNE 此效果无视效果免疫
EFFECT_FLAG_SET_AVAILABLE 此效果影响场上里侧的卡,或可在里侧状态发动
EFFECT_FLAG_CANNOT_INACTIVATE 此卡的发动不能被无效
EFFECT_FLAG_CANNOT_NEGATE 此效果的发动不能被无效
EFFECT_FLAG_CANNOT_DISABLE 此效果的效果不能被无效
EFFECT_FLAG_PLAYER_TARGET 此效果以玩家为对象
EFFECT_FLAG_BOTH_SIDE 此效果双方都能使用 如王宫的弹压
EFFECT_FLAG_COPY_INHERIT 此效果若被复制,则继承其Reset属性
EFFECT_FLAG_DAMAGE_STEP 此效果可以在伤害步骤发动
EFFECT_FLAG_DAMAGE_CAL 此效果可以在伤害计算时发动
EFFECT_FLAG_DELAY 此效果是“场合”效果(另开连锁)而非“时”效果
EFFECT_FLAG_SINGLE_RANGE 此效果只对持有效果的卡有效
EFFECT_FLAG_UNCOPYABLE 此效果不能复制
EFFECT_FLAG_OATH 此效果是对卡效果的誓约限制(发动无效不适用,效果无效也适用)
EFFECT_FLAG_SPSUM_PARAM 此效果将怪兽出场时需要遵守一定表示形式 用于EFFECT_SPSUMMON_PROC等正规召唤手续相关Code,在TargetRange设置
EFFECT_FLAG_REPEAT 此效果在场面变化后需要重新计算 只适用于永续效果
EFFECT_FLAG_NO_TURN_RESET 此效果的使用次数计数不随回合结束而重置 发条全家
EFFECT_FLAG_EVENT_PLAYER 此效果视为玩家进行的动作 影响效果处理的触发者是“效果持有者”还是“受影响的玩家/受影响的卡的持有者”
EFFECT_FLAG_OWNER_RELATE 此效果在效果持有者(Owner)失效后也失效
EFFECT_FLAG_CLIENT_HINT 此效果在触发时需要进行提示客户端 用于诸如全场代破的效果,让玩家知道效果适用
EFFECT_FLAG_CONTINUOUS_TARGET 此效果要与其他卡建立持续对象关系
EFFECT_FLAG_LIMIT_ZONE 此魔法·陷阱卡发动时只能在某些区域发动 如灵摆转移:要将卡转移到灵摆区,就不能在灵摆区发动
EFFECT_FLAG_IMMEDIATELY_APPLY 此效果在发动时而不是效果处理时就适用 基本上只用于永续效果。大概只能用于辅助其他事件?
EFFECT_FLAG2_COF 此通常魔法卡可以在主要阶段以外发动
!CATEGORY
CATEGORY_DESTROY 破坏效果
CATEGORY_RELEASE 解放效果
......@@ -344,7 +372,7 @@ CATEGORY_DICE 骰子效果
CATEGORY_LEAVE_GRAVE 涉及墓地的效果
CATEGORY_LVCHANGE 改变等级效果
CATEGORY_NEGATE 使发动无效效果
CATEGORY_ANNOUNCE 發動時宣言卡名的效果
CATEGORY_ANNOUNCE 发动時宣言卡名的效果
CATEGORY_FUSION_SUMMON 融合召唤效果
CATEGORY_TOEXTRA 回额外卡组效果
!TIMING
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment