Beispiel #1
0
func createMapMode(mode int, o *overlay.Overlay, dataParser func() (data.DefaultMap, error)) func(dom.Element) {
	submit := xform.InputSubmit("Create Map")
	submit.AddEventListener("click", false, func(e dom.Event) {
		data, err := dataParser()
		if err != nil {
			xjs.Alert("Error parsing values: %s", err)
			return
		}
		e.PreventDefault()
		go func() {
			err = RPC.CreateDefaultMap(data)
			if err != nil {
				xjs.Alert("Error creating map: %s", err)
				return
			}
			o.Close()
		}()
	})
	return func(c dom.Element) {
		xjs.AppendChildren(c,
			xjs.SetPreText(xdom.Div(), worldTypes[mode]),
			xdom.Br(),
			submit,
		)
	}
}
Beispiel #2
0
func createSuperFlatMap(o *overlay.Overlay, dataParser func() (data.DefaultMap, error)) func(dom.Element) {
	// create better UI here
	d := xdom.Div()
	gs := xform.InputText("settings", "0")
	gs.Required = true
	submit := xform.InputSubmit("Create Map")
	xjs.AppendChildren(d,
		xjs.SetPreText(xdom.Div(), worldTypes[1]),
		xform.Label("Generator Settings", "settings"),
		gs,
		xdom.Br(),
		submit,
	)
	submit.AddEventListener("click", false, func(e dom.Event) {
		d, err := dataParser()
		if err != nil {
			xjs.Alert("Error parsing values: %s", err)
			return
		}
		e.PreventDefault()
		go func() {
			err = RPC.CreateSuperflatMap(data.SuperFlatMap{
				DefaultMap:        d,
				GeneratorSettings: gs.Value,
			})
			if err != nil {
				xjs.Alert("Error creating map: %s", err)
				return
			}
			o.Close()

		}()
	})
	return func(c dom.Element) {
		c.AppendChild(d)
	}
}