You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
3.5 KiB
117 lines
3.5 KiB
1 year ago
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
using UniRx;
|
||
|
using UniRx.Triggers;
|
||
|
|
||
|
public class WaterSourceMenuPanel : UIView
|
||
|
{
|
||
|
//单位位置
|
||
|
public Toggle UnitLocToggle;
|
||
|
//地上消火栓
|
||
|
public Toggle DSXHSToggle;
|
||
|
//地下消火栓
|
||
|
public Toggle DXXHSToggle;
|
||
|
//天然水源
|
||
|
public Toggle TRSYToggle;
|
||
|
//消防水池
|
||
|
public Toggle XFSCToggle;
|
||
|
//上传按钮
|
||
|
public Button UploadButton;
|
||
|
//保存按钮
|
||
|
public Button SaveButton;
|
||
|
//清空按钮
|
||
|
public Button ClearButton;
|
||
|
//上传图片
|
||
|
public AnnotationOpenImage OpenImageFile;
|
||
|
public override void Awake()
|
||
|
{
|
||
|
base.Awake();
|
||
|
//单位位置
|
||
|
UnitLocToggle.OnValueChangedAsObservable()
|
||
|
.Subscribe(value =>
|
||
|
{
|
||
|
WaterSource.Instance.isCreate = value;
|
||
|
if (value)
|
||
|
WaterSource.Instance.Original = "Company";
|
||
|
else
|
||
|
WaterSource.Instance.Original = string.Empty;
|
||
|
});
|
||
|
//地上消火栓
|
||
|
DSXHSToggle.OnValueChangedAsObservable()
|
||
|
.Subscribe(value =>
|
||
|
{
|
||
|
WaterSource.Instance.isCreate = value;
|
||
|
if (value)
|
||
|
WaterSource.Instance.Original = "DSXHS";
|
||
|
else
|
||
|
WaterSource.Instance.Original = string.Empty;
|
||
|
});
|
||
|
//地下消火栓
|
||
|
DXXHSToggle.OnValueChangedAsObservable()
|
||
|
.Subscribe(value =>
|
||
|
{
|
||
|
WaterSource.Instance.isCreate = value;
|
||
|
if (value)
|
||
|
WaterSource.Instance.Original = "DXXHS";
|
||
|
else
|
||
|
WaterSource.Instance.Original = string.Empty;
|
||
|
});
|
||
|
//天然水源
|
||
|
TRSYToggle.OnValueChangedAsObservable()
|
||
|
.Subscribe(value =>
|
||
|
{
|
||
|
WaterSource.Instance.isCreate = value;
|
||
|
if (value)
|
||
|
WaterSource.Instance.Original = "TRSY";
|
||
|
else
|
||
|
WaterSource.Instance.Original = string.Empty;
|
||
|
});
|
||
|
//消防水池
|
||
|
XFSCToggle.OnValueChangedAsObservable()
|
||
|
.Subscribe(value =>
|
||
|
{
|
||
|
WaterSource.Instance.isCreate = value;
|
||
|
if (value)
|
||
|
WaterSource.Instance.Original = "XFSC";
|
||
|
else
|
||
|
WaterSource.Instance.Original = string.Empty;
|
||
|
});
|
||
|
//上传
|
||
|
UploadButton.OnClickAsObservable()
|
||
|
.Subscribe(_ =>
|
||
|
{
|
||
|
UploadButton.GetComponent<AnnotationOpenImage>().Output = WaterSource.Instance.SourceMap;
|
||
|
});
|
||
|
OpenImageFile.OnLoadTextureFinished = texture =>
|
||
|
{
|
||
|
UploadImage(texture);
|
||
|
};
|
||
|
//保存
|
||
|
SaveButton.OnClickAsObservable()
|
||
|
.Subscribe(_ => WaterSource.Instance.SaveData());
|
||
|
//清空
|
||
|
ClearButton.OnClickAsObservable()
|
||
|
.Subscribe(_ => WaterSource.Instance.OnClearData());
|
||
|
}
|
||
|
public override void Hide()
|
||
|
{
|
||
|
base.Hide();
|
||
|
UnitLocToggle.isOn = false;
|
||
|
DSXHSToggle.isOn = false;
|
||
|
DXXHSToggle.isOn = false;
|
||
|
TRSYToggle.isOn = false;
|
||
|
XFSCToggle.isOn = false;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 上传图片
|
||
|
/// </summary>
|
||
|
public void UploadImage(Texture2D texture)
|
||
|
{
|
||
|
HttpManager.Instance.PostImage($"WaterSource.jpg", texture, a =>
|
||
|
{
|
||
|
WaterSource.Instance.Data.ImageUrl = a?.ObjectName;
|
||
|
});
|
||
|
}
|
||
|
}
|