示例#1
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (B *Imp) Locate(x, y, w, h uint) {
	//
	if x+min > scr.NX() {
		x = scr.NX() - min
	}
	B.x0 = x
	if y+min > scr.NY() {
		y = scr.NY() - min
	}
	B.y0 = y
	if w < min {
		w = min
	}
	if B.x0+w > scr.NX() {
		w = scr.NX() - B.x0
	}
	B.width = w
	if h < min {
		h = min
	}
	if B.y0+h > scr.NY() {
		h = scr.NY() - B.y0
	}
	B.height = h
	scr.SaveGr(B.x0, B.y0, B.x0+B.width, B.y0+B.height)
}
示例#2
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (B *Imp) EditGr(s *string, x, y uint) {
	//
	if y >= scr.NY() {
		return
	}
	if x >= scr.NX()-scr.NX1() {
		return
	}
	n, b := uint(len(*s)), B.width
	if x+B.width*scr.NX1() > scr.NX() {
		B.width = (scr.NX() - uint(x)) / scr.NX1()
	}
	if B.width == 0 {
		B.width = n
	}
	if B.width < n {
		Norm(s, B.width)
	}
	//  if B.width > n { B.width = n }
	B.graphical = true
	if B.numerical || B.TRnumerical {
		B.editNumber(true, s, x, y)
	} else {
		B.editText(true, s, x, y)
	}
	B.width = b
}
示例#3
0
文件: imp.go 项目: CaptainSoOmA/Uni
func initialize() {
	//
	if !initialized {
		initialized = true
		scr.Switch(scr.XGA) // (scr.MaxMode())
		C.glViewport(0, 0, C.GLsizei(scr.NX()), C.GLsizei(scr.NY()))
	}
}
示例#4
0
文件: imp.go 项目: CaptainSoOmA/Uni
func sys(s species.System) {
	//
	ny = scr.NY()/species.Height - 2
	nx = scr.NX() / species.Width
	species.Sys(s)
	suffix = species.Suffix
	shadow = New()
}
示例#5
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (x *Imp) Locate() {
	//
	r := x.Radius()
	xm, ym := scr.MousePosGr()
	x.x, x.y = uint(xm), uint(ym)
	if x.x < r {
		x.x = r
	}
	if x.x+r >= scr.NY() {
		x.x = scr.NX() - 1 - r
	}
	if x.y < r {
		x.y = r
	}
	if x.y+r >= scr.NY() {
		x.y = scr.NY() - 1 - r
	}
}
示例#6
0
文件: imp.go 项目: CaptainSoOmA/Uni
func New() *Imp {
	//
	xx, yy = int(scr.NX()), int(scr.NY())
	f := new(Imp)
	f.Clr()
	//  f.sort = Pointset
	f.sort = Segments
	f.colour = col.ScreenF
	return f
}
示例#7
0
文件: imp.go 项目: CaptainSoOmA/Uni
func def(x, y, w float64) {
	//
	nX, nY = float64(scr.NX()), float64(scr.NY())
	x0, y0 = x, y
	if w <= 0 {
		width = 1
	} else {
		width = w
	}
	height = width / scr.Proportion()
	xm, ym = x0+width/2, y0+height/2
	mX, mY = nX/width, nY/height
}
示例#8
0
文件: imp.go 项目: CaptainSoOmA/Uni
func scale(x, y float64) (int, int) {
	//
	rx, ry := int(math.Trunc(mX*(x-x0))+0.5), int(math.Trunc(mY*(y-y0))+0.5)
	ry = int(scr.NY()) - ry
	if scr.UnderX() {
		if minInt <= rx && rx < maxInt && minInt <= ry && ry < maxInt {
			return rx, ry
		}
	} else if x0 <= x && x < x0+width && y0 <= y && y < y0+height {
		return rx, ry
	}
	return maxInt, maxInt
}
示例#9
0
文件: murus.go 项目: CaptainSoOmA/Uni
func moon(x0 int) {
	//
	const r = 40
	x, y, y1, ny := x0, r, 0, int(scr.NY())
	for y < ny-r {
		scr.SaveGr(uint(x-r), uint(y-r), uint(x+r), uint(y+r))
		scr.Colour(col.Sandgelb)
		scr.CircleFull(x, y, r)
		ker.Msleep(33)
		scr.RestoreGr(uint(x-r), uint(y-r), uint(x+r), uint(y+r))
		y1++
		y += y1
	}
}
示例#10
0
文件: col.go 项目: CaptainSoOmA/Uni
func colour(FZ, B uint) col.Colour {
	//
	MausAn := scr.MouseCursorOn()
	if !MausAn {
		scr.MouseCursor(true)
	}
	xm, ym := scr.MousePosGr()
	X, Y = uint(xm), uint(ym)
	M := FZ * B / 2
	if X >= scr.NY()-M {
		X = scr.NX() - M
	}
	if X >= M {
		X -= M
	} else {
		X = 0
	}
	if Y >= H {
		Y -= H
	} else {
		Y = 0
	}
	scr.SaveGr(X, Y, X+2*FZ*B, Y+H)
	write(FZ, B, X, Y)
	clicked := false
	C := col.ScreenF
loop:
	for {
		scr.MouseCursor(true)
		K, _ := kbd.Command()
		switch K {
		case kbd.Esc, kbd.Back, kbd.There, kbd.This:
			break loop
		case kbd.Here:
			define(FZ, B, &C)
			clicked = true
		case kbd.Hither:
			if clicked {
				break loop
			}
		}
	}
	scr.RestoreGr(X, Y, X+2*FZ*B, Y+H)
	if !MausAn {
		scr.MouseCursor(false)
	}
	return C
}
示例#11
0
文件: scr.go 项目: CaptainSoOmA/Uni
func init() {
	//
	colour = [max]col.Colour{col.LightCyan, col.LightYellow, col.Pink, col.LightGreen,
		col.LightWhite, col.Orange, col.LightBlue, col.Yellow,
		col.LightGreen, col.LightRed, col.LightMagenta, col.LightOrange}
	notUsedColour = col.DarkGray
	image = [max + 1]string{"Anaxagoras", "Aristoteles", "Cicero", "Demokrit",
		"Diogenes", "Epikur", "Heraklit", "Platon",
		"Protagoras", "Pythagoras", "Sokrates", "Thales",
		"Niemand"}
	for n := 0; n <= max; n++ {
		image[n] = env.Val("GOSRC") + "/murus/phil/pics/" + image[n]
	}
	const zweipi = float64(2 * math.Pi)
	text = [nStatuses]string{"    satt    ", "  hungrig   ", "sehr hungrig",
		"sehr hungrig", "sehr hungrig", "  speisend  "}
	thinkColour = col.ScreenB
	/*
	   if p > 6 {
	     if scr.UnderX () {
	       scr.Fullscreen()
	     }
	   }
	*/
	x0, y0 = scr.NX()/2, scr.NY()/2
	const f = float64(0.5)
	for p := uint(0); p < nPhilos; p++ {
		// Attention: the mathematical positiv sense is inverted on the scr, because lines count upwards !
		// middlepoint of plates:
		w, r := float64(p)/float64(nPhilos), 0.75*float64(y0)
		xt[p] = int(math.Trunc(r*math.Cos(zweipi*w)+f)) + int(x0)
		yt[p] = int(math.Trunc(-r*math.Sin(zweipi*w)+f)) + int(y0)
		// endpoints of the fork to the right (with the same number):
		w, r = w+0.5/float64(nPhilos), float64(y0)
		x[p] = int(math.Trunc(r*math.Cos(zweipi*w)+f)) + int(x0)
		y[p] = int(math.Trunc(-r*math.Sin(zweipi*w)+f)) + int(y0)
		r = r / 2.0
		x1[p] = int(math.Trunc(r*math.Cos(zweipi*w)+f)) + int(x0)
		y1[p] = int(math.Trunc(-r*math.Sin(zweipi*w)+f)) + int(y0)
		//    stat[p] = hungry
	}
}
示例#12
0
文件: murus.go 项目: CaptainSoOmA/Uni
func dr(x0, x1, y int, c col.Colour, f bool) {
	//
	const dx = 2
	nx1, ny, y1 := int(scr.NX1()), int(scr.NY()), 0
	for x := x0; x < x1; x += dx {
		if !f {
			scr.SaveGr(uint(x), uint(y), uint(x)+car.W, uint(y)+car.H)
		}
		car.Draw(true, c, x, y)
		ker.Msleep(10)
		car.Draw(true, col.ScreenB, x, y)
		if f && x > x0+26*nx1 && x%8 == 0 && y+car.H < ny {
			y1++
			y += y1
		}
		if !f {
			scr.RestoreGr(uint(x), uint(y), uint(x)+car.W, uint(y)+car.H)
		}
	}
}
示例#13
0
文件: imp.go 项目: CaptainSoOmA/Uni
func New(h bool) *Imp {
	//
	B := new(Imp)
	l := scr.NLines()
	c := scr.NX()
	B.max = 100
	B.horizontal = h
	B.value = 0
	if h {
		B.width = c
		B.height = scr.NY1()
		B.Locate(0, (l-1)*B.height, B.width, B.height)
	} else {
		B.width = scr.NX1()
		B.height = scr.NY()
		B.Locate(c-B.width, 0, B.width, B.height)
	}
	B.cF, B.cB = col.HintF, col.HintB
	B.Locate(B.x0, B.y0, B.width, B.height)
	return B
}
示例#14
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (B *Imp) WriteGr(s string, x, y int) {
	//
	if uint(y) >= scr.NY() {
		return
	}
	if uint(x) >= scr.NX()-scr.NX1() {
		return
	}
	n, b := uint(len(s)), B.width
	if B.width == 0 {
		B.width = n
	}
	if uint(x)+B.width*scr.NX1() > scr.NX() {
		B.width = (scr.NX() - uint(x)) / scr.NX1()
	}
	if B.width > n {
		B.width = n
	}
	if B.width < n {
		Norm(&s, B.width)
	}
	if B.numerical || B.TRnumerical {
		Move(&s, false)
	}
	scr.Lock()
	scr.Colours(B.cF, B.cB)
	if B.transparent {
		scr.SwitchTransparence(true)
	}
	scr.WriteGr(s, x, y)
	if B.transparent {
		scr.SwitchTransparence(false)
	}
	scr.Unlock()
	B.width = b
}
示例#15
0
文件: april.go 项目: CaptainSoOmA/Uni
func April1st() {
	col.ScreenF, col.ScreenB = col.White, col.Black
	scr.Cls()
	scr.MouseCursor(false)
	scr.Colour(col.White)
	scr.Write("Found evil software: \"       \"", 7, x0)
	doof(7, 22)
	scr.Colour(col.White)
	scr.Write("Remove (yes/no) ?", y0, x0)
	b := box.New()
	b.Wd(3)
	t := "yes"
	b.Edit(&t, y0, 23)
	scr.WarpMouseGr(2*int(scr.NX()), 2*int(scr.NY()))
	b.Colours(col.LightOrange, col.Black)
	b.Write("yes", y0, 23)
	doodle(col.LightWhite, 2)
	doodle(col.LightWhite, 2)
	doodle(col.LightYellow, 5)
	doodle(col.Yellow, 3)
	doodle(col.LightOrange, 5)
	doodle(col.Orange, 8)
	doodle(col.LightRed, 3)
	// TODO erase all (f + "*.tmp")
	t = str.Clr(70)
	scr.Write(t, y0, x0)
	scr.Write(t, y0+1, x0)
	col.ScreenF, col.ScreenB = col.LightGreen, col.DarkBlue
	scr.Cls()
	scr.Write("The murus-tool has removed \"       \" - your disk is reformatted :-)", y0, x0)
	doof(y0, 28)
	scr.Colour(col.LightWhite)
	scr.Write("Please install Linux, TeX, mercurial, Go and murus completely new !", y0+2, x0)
	ker.Sleep(20)
	ker.Terminate()
}
示例#16
0
文件: imp.go 项目: CaptainSoOmA/Uni
func print1() {
	//
	print_(0, 0, scr.NX(), scr.NY())
}
示例#17
0
文件: imp.go 项目: CaptainSoOmA/Uni
func surface(f RealFunc2, X, Y, Z, X1, Y1, Z1 float64, c col.Colour) {
	//
	if X == X1 || Y == Y1 || Z == Z1 {
		return
	}
	if X1 < X {
		X, X1 = X1, X
	}
	if Y1 < Y {
		Y, Y1 = Y1, Y
	}
	if Z1 < Z {
		Z, Z1 = Z1, Z
	}
	dx, dy := (X1-X)/float64(scr.NX()/grain), (Y1-Y)/float64(scr.NY()/grain)
	for x := X; x <= X1; x += dx {
		/*
		   y:= Y
		   n:= uint(0)
		   for y <= Y1 {
		     n ++
		     y += dy
		   }
		*/
		// die Anwendung der OpenGL-Ausgabe in gl von TriangleFan ist noch fehlerhaft
		x1, x0 := x+dx, x+dx/2.0
		//    temp, temp1:= vect.New (), vect.New ()
		//    v, n:= vectors (2 * n) // (2 * n + 1)                 ? ? ? ? ? ? ? ? ? ? ? ? ?
		for y := Y; y <= Y1; y += dy {
			/*
			   for i:= uint(0); i < n; i++ { // oder i <= n            ? ? ? ? ? ? ? ? ? ? ? ? ?
			     v[2 * i].Set3 (x, y,  z)
			     v[2 * i + 1].Set3 (x, y1, z1)
			     if i == 0 { // ?
			       n[0].Set3 (1, 1, 1)
			       n[0].Norm ()
			     } else {
			       temp.Diff (v[2 * i - 2], v[2 * i - 1])
			       temp1.Diff (v[2 * i], v[2 * i - 1])
			       n[2 * i - 1].Ext (temp, temp1)
			       n[2 * i - 1].Norm ()
			       temp.Diff (v[2 * i + 1], v[2 * i])
			       temp1.Diff (v[2 * i - 1], v[2 * i])
			       n[2 * i].Cross (temp, temp1)
			       n[2 * i].Dilate (-1)
			       n[2 * i].Norm ()
			     }
			     i ++
			*/
			y1, y0 := y+dy, y+dy/2.0
			z, z1, z2, z3 := f(x, y), f(x1, y), f(x1, y1), f(x, y1)
			z0 := f(x0, y0)
			b0 := true                     // ok (z)
			b1, b2, b3 := true, true, true // ok (z1), ok (z2), ok (z3)
			c0 := Z < z && z < Z1
			c1, c2, c3 := Z < z1 && z1 < Z1, Z < z2 && z2 < Z1, Z < z3 && z3 < Z1
			if ok(z0) && Z < z0 && z0 < Z1 {
				if b0 && b1 && c0 && c1 {
					triangle(x, y, z, x1, y, z1, x0, y0, z0, c)
				}
				if b1 && b2 && c1 && c2 {
					triangle(x1, y, z1, x1, y1, z2, x0, y0, z0, c)
				}
				if b2 && b3 && c2 && c3 {
					triangle(x1, y1, z2, x, y1, z3, x0, y0, z0, c)
				}
				if b3 && b0 && c3 && c0 {
					triangle(x, y1, z3, x, y, z, x0, y0, z0, c)
				}
			}
		}
		//    pts.Ins (pt.TriangleFan, 2 * n /* + 1 ? */, v, n, c)
	}
}
示例#18
0
文件: main.go 项目: CaptainSoOmA/Uni
func main() {
	//
	if !scr.MouseEx() {
		return
	}
	var symbol [Nfigure]byte
	symbol[line] = 'S'      // "Strecke"
	symbol[rectangle] = 'R' // "Rechteck"
	symbol[circle] = 'K'    // "Kreis"
	symbol[ellipse] = 'E'   // "Ellipse"
	X, Y := 0, 0
	X1, Y1 := scr.NX(), scr.NY()
	//  Farbe, Papier:= col.LightWhite, col.Black
	Farbe, Papier := col.Black, col.LightWhite
	col.ScreenF, col.ScreenB = Farbe, Papier
	scr.Cls()
	paintColour := Farbe
	scr.Colour(paintColour)
	//  Staerke = 3
	bx := box.New()
	bx.Wd(20)
	bx.Colours(Papier, Farbe)
	Name := env.Par(1)
	if str.Empty(Name) {
		Name = "temp"
	}
	scr.Save(0, 0, 20, 1)
	for {
		bx.Edit(&Name, 0, 0)
		if !str.Empty(Name) {
			str.RemSpaces(&Name)
			break
		}
	}
	scr.Restore(0, 0, 20, 1)
	img.Get(Name, uint(X), uint(Y))
	scr.MouseCursor(true)
	Figur := figure(rectangle)
	var x, y, x0, y0 int
loop:
	for {
		scr.Colour(paintColour)
		Zeichen, Kommando, T := kbd.Read()
		switch Kommando {
		case kbd.None:
			x, y = scr.MousePosGr()
			scr.SwitchTransparence(true)
			scr.Write1Gr(Zeichen, x, y-int(scr.NY1()))
			//    scr.WarpMouse (x + scr.NX1(), y)
		case kbd.Esc:
			break loop
		case kbd.Back:
			switch T {
			case 0:
				x, y = scr.MousePosGr()
				x -= int(scr.NX1())
				scr.Colour(Papier)
				scr.Write1Gr(' ', x, y-int(scr.NY1()))
				//        scr.RectangleFull (x, y - scr.NY1(), x + scr.NX1(), y)
				//        scr.WarpMouseGr (x, y)
				scr.Colour(paintColour)
			default:
				scr.Cls()
			}
			/*
			   case kbd.Ins:
			     img.Write (X, Y, X1, Y1 - 16, Name)
			     box.Edit (Feld, Name, scr.Zeilenzahl () - 1, 0)
			     img.Get (X, Y, Name)
			*/
		case kbd.Help:
			paintColour = sel.Colour()
			//    case kbd.LookFor:
			//      Staerke = Strichstaerken.Staerke()
		case kbd.Enter:
			if T > 0 {
				x0, y0 = scr.MousePosGr()
				//        scr.Fill1 (x0, y0)
			}
		case kbd.PrintScr:
			img.Print(uint(X), uint(Y), X1, Y1-16)
		case kbd.Tab:
			if T == 0 {
				if Figur+1 < Nfigure {
					Figur++
				} else {
					Figur = figure(0)
				}
			} else {
				if Figur > 0 {
					Figur--
				} else {
					Figur = figure(Nfigure - 1)
				}
			}
			scr.Colours(col.White, Papier)
			scr.Write1(symbol[Figur], scr.NY()-1, 0)
		case kbd.Here:
			x0, y0 = scr.MousePosGr()
			scr.CircleFull(x0, y0, 3/2)
		case kbd.Pull:
			x, y = scr.MousePosGr()
			scr.Line(x0, y0, x, y)
			x0, y0 = x, y
		case kbd.Hither:
			x, y = scr.MousePosGr()
			scr.Line(x0, y0, x, y)
		case kbd.There:
			x0, y0 = scr.MousePosGr()
			x, y = x0, y0
		case kbd.Push:
			paint(Figur, inv, x0, y0, x, y)
			x, y = scr.MousePosGr()
			paint(Figur, inv, x0, y0, x, y)
		case kbd.Thither:
			paint(Figur, inv, x0, y0, x, y)
			//      scr.Colour (paintColour)
			x, y = scr.MousePosGr()
			paint(Figur, border, x0, y0, x, y)
			x0, y0 = x, y
		case kbd.This:
			x0, y0 = scr.MousePosGr()
			x, y = x0, y0
		case kbd.Move:
			scr.LineInv(x0, y0, x, y)
			x, y = scr.MousePosGr()
			scr.LineInv(x0, y0, x, y)
		case kbd.Thus:
			scr.LineInv(x0, y0, x, y)
			x, y = scr.MousePosGr()
			scr.Line(x0, y0, x, y)
			x0, y0 = x, y
		}
	}
	scr.Save(0, 0, 20, 1)
	for {
		bx.Edit(&Name, 0, 0)
		// TODO make sure, that "Name" is x{x|y} where x is letter, y is digit
		if !str.Empty(Name) {
			str.RemSpaces(&Name)
			break
		}
	}
	scr.Restore(0, 0, 20, 1)
	img.Put(Name, uint(X), uint(Y), X1, Y1)
	ker.Terminate()
}
示例#19
0
文件: main.go 项目: CaptainSoOmA/Uni
func main() {
	//
	h := [...]string{
		// 0         1         2         3         4         5         6         7
		// 012345678901234567890123456789012345678901234567890123456789012345678901234567
		"   Art (Farbe) für neue Figur auswählen: (Umschalt- +) Leer- oder Rolltaste   ",
		//  "                 Schriftgröße auswählen: Alt- + Leer- oder Rolltaste          ",
		"                    neue Figur erzeugen: linke Maustaste,                     ",
		"                                         Streckenzüge, Polygone und Kurven    ",
		"                                         mit rechter Maustaste abschließen,   ",
		"                                         Texteingabe mit Eingabetaste beenden ",
		"                           Figur ändern: Alt- + linke Maustaste, die 'Punkte' ",
		"                                         mit rechter Maustaste verschieben,   ",
		"                                         mit linker Maustaste abschließen     ",
		"                           Figur färben: Umschalt-, Alt- + linke Maustaste    ",
		"             (alle) Figur(en) markieren: (Umschalt- +) F5-Taste oder          ",
		"                                         (Alt- +) mittlere Maustaste          ",
		"          (alle) Figur(en) entmarkieren: (Umschalt- +) F6-Taste oder          ",
		"                                         Umschalt- + (Alt- +) mittl. Maustaste",
		"           markierte Figur(en) kopieren: Umschalt- + linke Maustaste          ",
		"      (markierte) Figur(en) verschieben: (Umschalt- +) rechte Maustaste       ",
		"          (markierte) Figur(en) löschen: (Umschalt- +) Entfernungtaste oder   ",
		"                                         (Umschalt-,) Alt- + rechte Maustaste ",
		"     letzte gelöschte Figur zurückholen: Rücktaste (<-)                       ",
		"          letzte erzeugte Figur löschen: Umschalt- + Rücktaste (<-)           ",
		"letzte gelöschte mark. Fig. zurückholen: Alt- + Rücktaste (<-)                ",
		"Hintergrundfarbe umschalten (auswählen): (Umschalt- +) F4-Taste               ",
		" Figuren aus eBoard holen und markieren: F7-Taste                             ",
		"    markierte Figuren in eBoard ablegen: F8-Taste                             ",
		"                      eBoard ausdrucken: Drucktaste                           ",
		"                           ePen beenden: Abbruchtaste (Esc)                   ",
		"                                                                              ",
		"                  Steuerungstaste (Strg) wirkt wie Umschalttaste              "}
	help := make([]string, len(h))
	for i := 0; i < len(h); i++ {
		str.Set(&help[i], h[i])
	}
	scr.Switch(scr.SXGA)
	actColour = col.ScreenF
	paperColour = col.ScreenB
	//  fo = scr.Normal
	figure = fig2.New()
	newFigure := fig2.New()
	newFigure.SetColour(actColour)
	figures, copiedFigures, image = seq.New(newFigure), seq.New(newFigure), seq.New(newFigure)
	cuttedFigures, depot = seq.New(newFigure), seq.New(newFigure)
	stack = stk.New(newFigure)
	name, filename := names()
	if filename == "" {
		return
	}
	origname := filename
	load(figures, filename)
	//  extract (paperColour)
	write()
	var x0, y0 int // kbd.Push
	var movable bool
	var Schub int
loop:
	for {
		scr.MouseCursor(true)
		//    control(); write()
		c, cmd, d := kbd.Read()
		if cmd == kbd.None {
			switch c {
			case ' ':
				cmd = kbd.Roll
			}
		}
		xm, ym := scr.MousePosGr()
		switch d {
		case 0:
			Schub = 8
		case 1:
			Schub = int(scr.NY() / 40)
		default:
			Schub = int(scr.NX() / 8)
		}
		switch cmd {
		case kbd.Esc:
			break loop
		case kbd.Enter:
			// actualize ?
		case kbd.Back:
			switch d {
			case 0:
				ins(top())
			case 1:
				delLast()
			default:
				getMarked()
			}
		case kbd.Left:
			kick(spc.Right, Schub)
		case kbd.Right:
			Schub = -Schub
			kick(spc.Right, Schub)
		case kbd.Up:
			kick(spc.Top, Schub)
		case kbd.Down:
			Schub = -Schub
			kick(spc.Top, Schub)
		case kbd.Del:
			switch d {
			case 0:
				if deleted(xm, ym) {
					push()
				}
			default:
				delMarked()
			}
		case kbd.Tab:
			// free for use
		case kbd.Help:
			scr.SwitchFontsize(font.Normal)
			errh.WriteHelp(help)
		case kbd.LookFor:
			// wird für die Auswahl des eBoards verwendet - NEIN, sondern:
			load(figures, filename)
			write()
		case kbd.Act:
			//      inject (paperColour)
			store(figures, filename)
		case kbd.Cfg:
			paperColour = sel.Colour()
			bgColour(paperColour)
		case kbd.Mark:
			switch d {
			case 0:
				mark(xm, ym, true)
			case 1:
				markAll(true)
			default:
				showMarked()
			}
		case kbd.Demark:
			switch d {
			case 0:
				mark(xm, ym, false)
			case 1:
				markAll(false)
			default:
				showMarked()
			}
		case kbd.Deposit:
			writeMarked()
		case kbd.Paste:
			readMarked()
		case kbd.PrintScr:
			print(name)
		case kbd.Roll:
			switch d {
			case 0:
				newFigure.Select()
			case 1:
				actColour = sel.Colour()
				newFigure.SetColour(actColour)
			case 2:
				scr.SwitchFontsize(font.Normal)
				//        fo = sel.Size (actColour)
				//        newFigure.SetFont (fo)
			}
		case kbd.Here:
			switch d {
			case 0:
				generate(newFigure)
			case 1:
				copyMarked()
			case 2:
				change(xm, ym)
			case 3:
				setColours(xm, ym, actColour)
			}
		case kbd.There:
			movable = underMouse(uint(xm), uint(ym)) && d <= 1
			x0, y0 = xm, ym // kbd.Push
			switch d {
			case 0:
				if movable {
					cut(xm, ym)
				}
			case 1:
				if movable {
					cutMarked()
				}
			case 2:
				if deleted(xm, ym) {
					push()
				}
			default:
				delMarked()
				write()
			}
		case kbd.Push:
			if movable {
				switch d {
				case 0:
					move(xm-x0, ym-y0)
				case 1:
					moveMarked(xm-x0, ym-y0)
				}
				x0, y0 = scr.MousePosGr()
			}
		case kbd.Thither:
			if movable {
				switch d {
				case 0:
					join()
				case 1:
					joinMarked()
				}
			}
		case kbd.This:
			switch d {
			case 0:
				mark(xm, ym, true)
			case 1:
				mark(xm, ym, false)
			case 2:
				markAll(true)
			case 3:
				markAll(false)
			}
			invMarked()
		case kbd.Thus:
			invMarked()
		}
	}
	markAll(false)
	_, filename = names()
	if filename == "" {
		filename = origname
	}
	//  inject (paperColour)
	store(figures, filename) // -> Terminieren
	ker.Terminate()
}
示例#20
0
文件: imp.go 项目: CaptainSoOmA/Uni
func edit() {
	//
	var d uint
	c := kbd.LastCommand(&d)
	if d > 2 {
		d = 2
	}
	switch c {
	case kbd.Back:
		if width < maxWidth {
			w := width * mm[d]
			if w > maxWidth {
				w = maxWidth
			}
			dw := (w - width) / 2
			x0, y0 = x0-dw, y0-dw/scr.Proportion()
			width = w
		} else { // überschritten
			x0, y0 = xMin, yMin
			width = maxWidth
		}
		height = width / scr.Proportion()
		mX, mY = nX/width, nY/height
	case kbd.Enter:
		if width > maxWidth/maxMag {
			w := width / mm[d]
			if w < maxWidth/maxMag {
				w = maxWidth / maxMag
			}
			dw := (w - width) / 2
			x0, y0 = x0-dw, y0-dw/scr.Proportion()
			width = w
			height = width / scr.Proportion()
			mX, mY = nX/width, nY/height
		}
	case kbd.Left:
		if x0 >= xMin {
			x0 = x0 - width/nn[d]
		}
	case kbd.Right:
		if x0+width <= xMin+maxWidth {
			x0 = x0 + width/nn[d]
		}
		// TODO: Rollrad von Maus einbauen - die sendet Up/Down
	case kbd.Up:
		if y0+height < yMin+maxHeight {
			y0 = y0 + width/nn[d]
		}
	case kbd.Down:
		if y0 >= yMin {
			y0 = y0 - width/nn[d]
		}
	case kbd.This:
		x, y := scr.MousePosGr()
		y = int(scr.NY()) - y
		x0 = x0 + float64(x)/mX - width/2
		y0 = y0 + float64(y)/mY - height/2
	case kbd.There:
		x, y := scr.MousePosGr()
		xt, yt = float64(x), float64(int(scr.NY())-y)
	case kbd.Push, kbd.Thither:
		x, y := scr.MousePosGr()
		x0 = x0 - (float64(x)-xt)/mX
		y0 = y0 - (float64(int(scr.NY())-y)-yt)/mY
		xt, yt = float64(x), float64(int(scr.NY())-y)
	}
	if x0 < xMin {
		x0 = xMin
	}
	if x0+width > xMin+maxWidth {
		x0 = xMin + maxWidth - width
	}
	if y0 < yMin {
		y0 = yMin
	}
	if y0+height >= yMin+maxHeight {
		y0 = yMin + maxHeight - height
	}
}
示例#21
0
文件: imp.go 项目: CaptainSoOmA/Uni
func rescale(x, y int) (float64, float64) {
	//
	return x0 + float64(x)/mX, y0 + float64(int(scr.NY())-y)/mY
}
示例#22
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (R *Imp) Manipulieren(K kbd.Comm, T uint) {
	//
	s := schrittweise
	schrittweise = false
	amEditieren = true
	switch K {
	case kbd.Esc:
		return
	case kbd.Enter:
		if T == 0 {
			if R.Geschoben1() {
			}
		} else {
			R.schiessen()
		}
	case kbd.Left:
		if Sokoban {
			switch R.richtung {
			case Nord:
				R.LinksDrehen()
			case West:

			case Sued:
				R.RechtsDrehen()
			case Ost:
				R.umkehren()
			}
			if R.NachbarLeer() {
				if R.Gelaufen1() {
				}
			} else {
				if R.Geschoben1() {
				}
			}
		} else {
			switch R.richtung {
			case Nord:
				R.LinksDrehen()
			case West:
				if T == 0 {
					if R.Gelaufen1() {
					}
				} else {
					for R.Gelaufen1() {
					}
				}
			case Sued:
				R.RechtsDrehen()
			case Ost:
				R.umkehren()
			}
		}
	case kbd.Right:
		if Sokoban {
			switch R.richtung {
			case Nord:
				R.RechtsDrehen()
			case West:
				R.umkehren()
			case Sued:
				R.LinksDrehen()
			case Ost:

			}
			if R.NachbarLeer() {
				if R.Gelaufen1() {
				}
			} else {
				if R.Geschoben1() {
				}
			}
		} else {
			switch R.richtung {
			case Nord:
				R.RechtsDrehen()
			case West:
				R.umkehren()
			case Sued:
				R.LinksDrehen()
			case Ost:
				if T == 0 {
					if R.Gelaufen1() {
					}
				} else {
					for R.Gelaufen1() {
					}
				}
			}
		}
	case kbd.Up:
		if Sokoban {
			switch R.richtung {
			case Nord:

			case West:
				R.RechtsDrehen()
			case Sued:
				R.umkehren()
			case Ost:
				R.LinksDrehen()
			}
			if R.NachbarLeer() {
				if R.Gelaufen1() {
				}
			} else {
				if R.Geschoben1() {
				}
			}
		} else {
			if T == 2 {
				R.Entmarkieren()
			} else {
				switch R.richtung {
				case Nord:
					if T == 0 {
						if R.Gelaufen1() {
						}
					} else {
						for R.Gelaufen1() {
						}
					}
				case West:
					R.RechtsDrehen()
				case Sued:
					R.umkehren()
				case Ost:
					R.LinksDrehen()
				}
			}
		}
	case kbd.Down:
		if Sokoban {
			switch R.richtung {
			case Nord:
				R.umkehren()
			case West:
				R.LinksDrehen()
			case Sued:

			case Ost:
				R.RechtsDrehen()
			}
			if R.NachbarLeer() {
				if R.Gelaufen1() {
				}
			} else {
				if R.Geschoben1() {
				}
			}
		} else {
			if T == 2 {
				R.Markieren()
			} else {
				switch R.richtung {
				case Nord:
					R.umkehren()
				case West:
					R.LinksDrehen()
				case Sued:
					if T == 0 {
						if R.Gelaufen1() {
						}
					} else {
						for R.Gelaufen1() {
						}
					}
				case Ost:
					R.RechtsDrehen()
				}
			}
		}
	case kbd.Pos1:
		if !Sokoban {
			if R.Gemauert1() {
			}
		}
	case kbd.End:
		if !Sokoban {
			if R.Entmauert1() {
			}
		}
	case kbd.Tab:
		if !Sokoban {
			switch T {
			case 0:
				if Roboterwelt.markiert(R.Y, R.X) {
					R.Entmarkieren()
				} else {
					R.Markieren()
				}
				/*
				     R.Markieren ()
				   1: // unter X funktioniert Umschalt + Tab nicht
				     R.Entmarkieren ()
				   } else {
				     R.allesEntmarkieren ()
				*/
			}
		}
	case kbd.Ins:
		if !Sokoban {
			if R.tasche > 0 {
				R.Legen1()
			}
		}
	case kbd.Del:
		if !Sokoban {
			if T == 0 {
				R.Leeren1()
			} else {
				Roboterwelt.klotzen(R.Y, R.X, 0)
			}
		}
	case kbd.Back:
		for len(R.aktionen) > 0 {
			switch R.letzteAktion() {
			case Links:
				R.linksDrehenZurueck()
			case Rechts:
				R.rechtsDrehenZurueck()
			case Weiter:
				R.laufen1zurueck()
			case Zurueck:
				R.zuruecklaufen1zurueck()
			case KlotzWeg:
				R.leeren1zurueck()
			case KlotzHin:
				R.legen1zurueck()
			case KlotzWeiter:
				R.schieben1zurueck()
			case MarkeHin:
				R.markierenZurueck()
			case MarkeWeg:
				R.entmarkierenZurueck()
			case MauerHin:
				R.mauern1zurueck()
			case MauerWeg:
				R.entmauern1zurueck()
			}
			if T == 0 {
				break
			}
		}
	case kbd.Help:
		if Sokoban {
			errh.WriteHelp(Sokobanhilfe[:])
		} else {
			errh.WriteHelp(Hilfe[:])
		}
	case kbd.LookFor:
		// Roboter wechseln
	case kbd.Act:
		// neuen Roboter initialisieren
	case kbd.Cfg:
		// terminieren (R)
	case kbd.Mark:
		if !Sokoban {
			R.Markieren()
		}
	case kbd.Demark:
		if !Sokoban {
			if T == 0 {
				R.Entmarkieren()
			} else {
				R.allesEntmarkieren()
			}
		}
	case kbd.Paste:

	case kbd.Deposit:

	case kbd.Black:

	case kbd.Red:

	case kbd.Green:

	case kbd.Blue:

	case kbd.PrintScr:
		img.Print(0, 0, scr.NX(), scr.NY()-scr.NY1())
	case kbd.Roll:
		if T == 0 {
			// Roboter wechseln
		} else {
			// terminieren (R)
		}
	case kbd.Pause:
		// Roboter killen
	case kbd.Go:

		/*
		   case kbd.Here:
		     if scr.UnderMouse (2 * R.Y + 1, 4 * R.X, 4, 2) {
		       // ist angeklickt
		     }
		*/
	case kbd.Pull:
		// wenn Roboter getroffen, vorläufig hierhin
	case kbd.Hither:
		// wenn Roboter getroffen, endgültig hierhin
	case kbd.There:

	case kbd.Push:

	case kbd.Thither:

	case kbd.This:

	case kbd.Move:

	case kbd.Thus:

	case kbd.Navigate:

	}
	amEditieren = false
	schrittweise = s
}