extern heliport.v3.storage{ JsVal getLocalStorageValue(string); void setLocalStorageValue(string,string); } extern heliport.v3.api.ingameMessage{ void getIngameMessages(async fJsValCallback, string, string, string); } //delegate void callbackdelegate(string); // extern // { // //float get_size_texrarea(JsVal val); // } const string MessageType_Toast = "toast"; const string MessageType_System = "system"; const string MessageType_ToastAndSystem = "toast_and_system"; const string MessageType_Modal = "modal"; const string LocalStorage_HideNotification = "notification_hide"; class IngameMessage { public int id ; public string title ; public string message ; public string url ; public string message_type ; public bool no_worlds ; public bool official_worlds ; public bool ugc_worlds ; public bool rooms ; public bool selected_worlds ; public bool selected_rooms ; public bool no_events ; public bool official_events ; public bool user_events ; public bool selected_events ; public string notification_type; public bool is_immediately ; public string start_at ; public string end_at ; public string platform_code ; public string created_at ; public string updated_at ; public IngameMessage() { //message_typeが指定の値でない場合表示はされない処理になっているので、これを無効値判定に使う message_type = ""; } public void SetFromParams(int _id, string _title, string _message, string _url, string _message_type, bool _no_worlds, bool _official_worlds, bool _ugc_worlds, bool _rooms, bool _selected_worlds, bool _selected_rooms, bool _no_events, bool _official_events, bool _user_events, bool _selected_events, string _notification_type, bool _is_immediately, string _start_at, string _end_at, string _platform_code, string _created_at, string _updated_at) { this.id = _id; this.title = _title; this.message = _message; this.url = _url; this.message_type = _message_type; this.no_worlds = _no_worlds; this.official_worlds = _official_worlds; this.ugc_worlds = _ugc_worlds; this.rooms = _rooms; this.selected_worlds = _selected_worlds; this.selected_rooms = _selected_rooms; this.no_events = _no_events; this.official_events = _official_events; this.user_events = _user_events; this.selected_events = _selected_events; this.notification_type = _notification_type; this.is_immediately = _is_immediately; this.start_at = _start_at; this.end_at = _end_at; this.platform_code = _platform_code; this.created_at = _created_at; this.updated_at = _updated_at; } public void Set(IngameMessage src) { this.id = src.id; this.title = src.title; this.message = src.message; this.url = src.url; this.message_type = src.message_type; this.no_worlds = src.no_worlds; this.official_worlds = src.official_worlds; this.ugc_worlds = src.ugc_worlds; this.rooms = src.rooms; this.selected_worlds = src.selected_worlds; this.selected_rooms = src.selected_rooms; this.no_events = src.no_events; this.official_events = src.official_events; this.user_events = src.user_events; this.selected_events = src.selected_events; this.notification_type = src.notification_type; this.is_immediately = src.is_immediately; this.start_at = src.start_at; this.end_at = src.end_at; this.platform_code = src.platform_code; this.created_at = src.created_at; this.updated_at = src.updated_at; } public void ParseFromJson(Json ingameMessagesElement) { ingameMessagesElement.FindValueInt ("id" , id ); ingameMessagesElement.FindValueString("title" , title ); ingameMessagesElement.FindValueString("message" , message ); ingameMessagesElement.Find (EJSONDataType_Block, "thumbnail" ).FindValueString("url", url); ingameMessagesElement.FindValueString("message_type" , message_type ); ingameMessagesElement.FindValueBool ("no_worlds" , no_worlds ); ingameMessagesElement.FindValueBool ("official_worlds" , official_worlds ); ingameMessagesElement.FindValueBool ("ugc_worlds" , ugc_worlds ); ingameMessagesElement.FindValueBool ("rooms" , rooms ); ingameMessagesElement.FindValueBool ("selected_worlds" , selected_worlds ); ingameMessagesElement.FindValueBool ("selected_rooms" , selected_rooms ); ingameMessagesElement.FindValueBool ("no_events" , no_events ); ingameMessagesElement.FindValueBool ("official_events" , official_events ); ingameMessagesElement.FindValueBool ("user_events" , user_events ); ingameMessagesElement.FindValueBool ("selected_events" , selected_events ); ingameMessagesElement.FindValueString("notification_type", notification_type); ingameMessagesElement.FindValueBool ("is_immediately" , is_immediately ); ingameMessagesElement.FindValueString("start_at" , start_at ); ingameMessagesElement.FindValueString("end_at" , end_at ); ingameMessagesElement.FindValueString("platform_code" , platform_code ); ingameMessagesElement.FindValueString("created_at" , created_at ); ingameMessagesElement.FindValueString("updated_at" , updated_at ); } public void ParseFromJsVal(JsVal ingameMessagesElement) { id = ingameMessagesElement.GetProperty("id" ).GetNum (); title = ingameMessagesElement.GetProperty("title" ).GetStr (); message = ingameMessagesElement.GetProperty("message" ).GetStr (); url = ingameMessagesElement.GetProperty("thumbnail" ).GetProperty("url").GetStr (); message_type = ingameMessagesElement.GetProperty("message_type" ).GetStr (); no_worlds = ingameMessagesElement.GetProperty("no_worlds" ).GetBool(); official_worlds = ingameMessagesElement.GetProperty("official_worlds" ).GetBool(); ugc_worlds = ingameMessagesElement.GetProperty("ugc_worlds" ).GetBool(); rooms = ingameMessagesElement.GetProperty("rooms" ).GetBool(); selected_worlds = ingameMessagesElement.GetProperty("selected_worlds" ).GetBool(); selected_rooms = ingameMessagesElement.GetProperty("selected_rooms" ).GetBool(); no_events = ingameMessagesElement.GetProperty("no_events" ).GetBool(); official_events = ingameMessagesElement.GetProperty("official_events" ).GetBool(); user_events = ingameMessagesElement.GetProperty("user_events" ).GetBool(); selected_events = ingameMessagesElement.GetProperty("selected_events" ).GetBool(); notification_type= ingameMessagesElement.GetProperty("notification_type").GetStr (); is_immediately = ingameMessagesElement.GetProperty("is_immediately" ).GetBool(); start_at = ingameMessagesElement.GetProperty("start_at" ).GetStr (); end_at = ingameMessagesElement.GetProperty("end_at" ).GetStr (); platform_code = ingameMessagesElement.GetProperty("platform_code" ).GetStr (); created_at = ingameMessagesElement.GetProperty("created_at" ).GetStr (); updated_at = ingameMessagesElement.GetProperty("updated_at" ).GetStr (); } public string ToString(){ return ("id" + " : %d\n" % id )+ ("title" + " : %s\n" % title )+ ("message" + " : %s\n" % message )+ ("thumbnail" + " : %s\n" % url )+ ("message_type" + " : %s\n" % message_type )+ ("no_worlds" + " : %b\n" % no_worlds )+ ("official_worlds" + " : %b\n" % official_worlds )+ ("ugc_worlds" + " : %b\n" % ugc_worlds )+ ("rooms" + " : %b\n" % rooms )+ ("selected_worlds" + " : %b\n" % selected_worlds )+ ("selected_rooms" + " : %b\n" % selected_rooms )+ ("no_events" + " : %b\n" % no_events )+ ("official_events" + " : %b\n" % official_events )+ ("user_events" + " : %b\n" % user_events )+ ("selected_events" + " : %b\n" % selected_events )+ ("notification_type"+ " : %s\n" % notification_type)+ ("is_immediately" + " : %b\n" % is_immediately )+ ("start_at" + " : %s\n" % start_at )+ ("end_at" + " : %s\n" % end_at )+ ("platform_code" + " : %s\n" % platform_code )+ ("created_at" + " : %s\n" % created_at )+ ("updated_at" + " : %s\n" % updated_at ); } } class NotificationWindowModel { NotificationWindowViewModel m_ViewModel; list m_notifications; IngameMessage m_im; Func m_lateInvokeDelegate; public NotificationWindowModel() { m_ViewModel = system.Layer_GetComponentByName("notification_window_with_image"); } public void FetchNotification(){ heliport.v3.api.ingameMessage.getIngameMessages(_fetchNotificationCallback,hsGetPlatformCode(),"",""); } public void NextNotification(){ _ShowNext(); } public void AddHideNotification(){ if(m_im === null)return; JsVal val = heliport.v3.storage.getLocalStorageValue(LocalStorage_HideNotification); ReturnType result = hsLoadReturnType(val); if(!result.IsValid()) return; string data = result.data.GetStr(); list strings = data.Split("|"); for(int i = 0;i < strings.Count; i++){ if(strings[i] == m_im.id.ToString()){ //もうあるので何もしない return; } } //ここまで来たということは保存されていなかったということなので追加する data = data + "|" + m_im.id.ToString(); heliport.v3.storage.setLocalStorageValue(LocalStorage_HideNotification,data); } public void RemoveHideNotification(){ if(m_im === null)return; JsVal val = heliport.v3.storage.getLocalStorageValue(LocalStorage_HideNotification); ReturnType result = hsLoadReturnType(val); if(!result.IsValid()) return; string data = result.data.GetStr(); list strings = data.Split("|"); data = ""; for(int i = 0;i < strings.Count; i++){ if(strings[i] == m_im.id.ToString()){ //とばす continue; } if(i==0){ data = strings[i]; } else{ data = data + "|" + strings[i]; } } heliport.v3.storage.setLocalStorageValue(LocalStorage_HideNotification,data); } void _ShowNext(){ if(m_notifications === null)return; if(!m_lateInvokeDelegate.IsEmpty())return; if(m_notifications.Count > 0){ int c = m_notifications.Count; for(int i = 0 ; i < c ; i++){ _AnalyseNotificationJSON(m_notifications[0]); m_notifications.RemoveAt(0); if(!(m_im === null))break; if(m_notifications.Count <= 0){ m_notifications = null; break; } } } } void _fetchNotificationCallback(JsVal val) { ReturnType result = hsLoadReturnType(val); if(!result.IsValid()) return; list props1 = result.data.GetPropertyList(); list props2 = props1[0].GetValue().GetPropertyList(); m_notifications = new list(); for(int i=0;i strings = data.Split("|"); for(int i = 0;i < strings.Count; i++){ if(strings[i] == id.ToString()){ //存在しているので表示しない return true; } } return false; } public void Update() { if (!m_lateInvokeDelegate.IsEmpty()) { m_lateInvokeDelegate(); Func tmp; m_lateInvokeDelegate = tmp; } } }