]> git.lizzy.rs Git - plan9front.git/commitdiff
merge
authorcinap_lenrek <cinap_lenrek@felloff.net>
Sat, 11 Mar 2017 19:42:25 +0000 (20:42 +0100)
committercinap_lenrek <cinap_lenrek@felloff.net>
Sat, 11 Mar 2017 19:42:25 +0000 (20:42 +0100)
lib/legal/NOTICE
lib/legal/mit [new file with mode: 0644]
sys/man/1/galaxy
sys/src/games/galaxy/galaxy.c

index ccec51249ee8c72ef55141efc8eed437cdc2d554..8afa4e4f3829ad9df1b4f933956bfd871616f0d0 100644 (file)
@@ -1,6 +1,11 @@
-The Plan 9 software is provided under the terms of the
-Lucent Public License, Version 1.02, reproduced in the
-file /lib/legal/lpl, with the following notable exceptions:
+Plan 9 from Bell Labs is provided under the terms of the Lucent Public License,
+Version 1.02, reproduced in the file /lib/legal/lpl.
+
+Any additions or changes (as recorded in Mercurial history) made by 9front are provided
+under the terms of the MIT License, reproduced in the file /lib/legal/mit, unless
+otherwise indicated.
+
+The following exceptions apply:
 
 1. No right is granted to create derivative works of or
    to redistribute (other than with the Plan 9 Operating System)
@@ -11,11 +16,19 @@ file /lib/legal/lpl, with the following notable exceptions:
    These directories contain material copyrights by B&H Inc. and Y&Y Inc.
 
 2. The printer fonts identified in subdirectory /sys/lib/ghostscript/font
-   are subject to the GNU GPL, reproduced in the file /lib/legal/gpl.
+   are subject to the GNU GPL, version 2, reproduced in the file /lib/legal/gpl.
 
 3. The ghostscript program in the subdirectory /sys/src/cmd/gs is
    covered by the Aladdin Free Public License, reproduced in the file
    /lib/legal/afpl.
 
+4. The Python programming language in the subdirectories /sys/src/cmd/python and
+   /sys/lib/python is covered by the Python Software Foundation License, reproduced
+   in the file /sys/src/cmd/python/LICENSE.
+
+5. The Mercurial version control system in the subdirectories /sys/src/cmd/hg and
+   /sys/lib/mercurial is covered by the GNU GPL, version 2, reproduced in
+   the file /lib/legal/gpl.
+
 Other, less notable exceptions are marked in the file tree with
 COPYING, COPYRIGHT, or LICENSE files.
diff --git a/lib/legal/mit b/lib/legal/mit
new file mode 100644 (file)
index 0000000..95f1602
--- /dev/null
@@ -0,0 +1,19 @@
+Copyright (c) 20XX 9front
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
index a6b4b2279e5bd708d1bc3c55b823124d0263f645..188c83e61f56ccab5866faf189026ed235bb3940 100644 (file)
@@ -38,23 +38,20 @@ option. If no file is read then the simulator starts with an empty
 universe.
 .SS Mouse commands
 .PP
-New planetary bodies can be created with mouse button 1.
-Holding button 1 will reposition the body.
+Holding mouse button 1 while dragging repositions the visible region of
+the galaxy. Holding mouse button 2 while dragging up or down zooms the
+visible region of the galaxy in or out, respectively.
+Mouse button 3 opens a menu with the following options:
+.TP
+.B "new body"
+Creates a new galactic body.
+Holding button 1 positions the body.
 Holding a button 1-2 chord changes the mass/size
 of the body. Holding a button 1-3 chord
 changes the initial velocity of the body. Releasing button 1
 restarts the simulator with the new body in motion. When new
 bodies are created, the simulator maintains the Galilean (inertial)
 reference frame where the center of mass of the galaxy is at rest.
-.PP
-Mouse button 2 repositions the visible region of the galaxy by dragging.
-.PP
-Mouse button 3 opens a menu with the following options:
-.TP
-.B zoom
-Prompts for a floating point value to change the scale of the
-simulation. E.g. a value of 2 will halve the scale (zoom in)
-and a value of 0.5 will double the scale (zoom out).
 .TP
 .B speed
 Prompts for a floating point value to change the speed of
index 28fc38a21e90f7f090f214126bd15bae1ce44e0a..d81b341236733cc00531944785eb12b47309b5b1 100644 (file)
@@ -20,6 +20,18 @@ Cursor crosscursor = {
         0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, }
 };
 
+Cursor zoomcursor = {
+       {-7, -7},
+       {0x1F, 0xF8, 0x3F, 0xFC, 0x7F, 0xFE, 0xFB, 0xDF,
+        0xF3, 0xCF, 0xE3, 0xC7, 0xFF, 0xFF, 0xFF, 0xFF,
+        0xFF, 0xFF, 0xFF, 0xFF, 0xE3, 0xC7, 0xF3, 0xCF,
+        0x7B, 0xDF, 0x7F, 0xFE, 0x3F, 0xFC, 0x1F, 0xF8, },
+       {0x00, 0x00, 0x0F, 0xF0, 0x31, 0x8C, 0x21, 0x84,
+        0x41, 0x82, 0x41, 0x82, 0x41, 0x82, 0x7F, 0xFE,
+        0x7F, 0xFE, 0x41, 0x82, 0x41, 0x82, 0x41, 0x82,
+        0x21, 0x84, 0x31, 0x8C, 0x0F, 0xF0, 0x00, 0x00, }
+};
+
 Cursor pausecursor={
        0, 0,
        0x01, 0x80, 0x03, 0xC0, 0x07, 0xE0, 0x07, 0xe0,
@@ -35,7 +47,7 @@ Cursor pausecursor={
 
 enum {
        STK = 8192,
-       ZOOM = 0,
+       DOBODY = 0,
        SPEED,
        GRAV,
        SAVE,
@@ -56,12 +68,12 @@ double
        LIM = 10,
        dt²;
 char *file;
-int showv, showa, throttle;
+int showv, showa, throttle, paused;
 
 char *menustr[] = {
+       [DOBODY]        "new body",
        [SAVE]  "save",
        [LOAD]  "load",
-       [ZOOM]  "zoom",
        [SPEED] "speed",
        [GRAV]  "gravity",
        [EXIT]  "exit",
@@ -106,7 +118,7 @@ randcol(void)
 void
 pause(int p, int id)
 {
-       static int paused, pid = -1;
+       static int pid = -1;
 
        switch(p) {
        default:
@@ -253,7 +265,15 @@ dobody(void)
        double f;
        Body *b;
 
-       pause(0, 0);
+       for(;;) {
+               readmouse(mc);
+               if(mc->buttons == 0)
+                       continue;
+               if(mc->buttons == 1)
+                       break;
+               return;
+       }
+
        b = body();
        setpos(b);
        setvel(b);
@@ -278,8 +298,6 @@ dobody(void)
        gc = center();
        orig.x += gc.x / scale;
        orig.y += gc.y / scale;
-
-       pause(1, 0);
 }
 
 char*
@@ -316,17 +334,43 @@ domove(void)
        Point oldp, off;
 
        setcursor(mc, &crosscursor);
-       pause(0, 0);
        oldp = mc->xy;
        for(;;) {
                readmouse(mc);
-               if(mc->buttons != 2)
+               if(mc->buttons != 1)
                        break;
                off = subpt(mc->xy, oldp);
                oldp = mc->xy;
+               pause(0, 0);
                orig = addpt(orig, off);
                drawglxy();
+               pause(1, 0);
+       }
+       setcursor(mc, cursor);
+}
+
+void
+dozoom(void)
+{
+       Point z, d;
+       double f, olds;
+
+       setcursor(mc, &zoomcursor);
+
+       z = mc->xy;
+       olds = scale;
+       for(;;) {
+               readmouse(mc);
+               if(mc->buttons != 2)
+                       break;
+               d = subpt(mc->xy, z);
+               f = tanh((double)d.y/200) + 1;
+               pause(0, 0);
+               scale = f*olds;
+               drawglxy();
+               pause(1, 0);
        }
+
        setcursor(mc, cursor);
        pause(1, 0);
 }
@@ -349,6 +393,9 @@ domenu(void)
 
        pause(0, 0);
        switch(menuhit(3, mc, &menu, nil)) {
+       case DOBODY:
+               dobody();
+               break;
        case SAVE:
                s = getinput("Enter file:", file);
                if(s == nil || *s == '\0')
@@ -373,16 +420,6 @@ domenu(void)
                load(fd);
                close(fd);
                break;
-       case ZOOM:
-               s = getinput("Zoom multiplier:", nil);
-               if(s == nil || *s == '\0')
-                       break;
-               z = strtod(s, nil);
-               free(s);
-               if(z <= 0)
-                       break;
-               scale /= z;
-               break;
        case SPEED:
                s = getinput("Speed multiplier:", nil);
                if(s == nil || *s == '\0')
@@ -420,10 +457,10 @@ mousethread(void*)
                readmouse(mc);
                switch(mc->buttons) {
                case 1:
-                       dobody();
+                       domove();
                        break;
                case 2:
-                       domove();
+                       dozoom();
                        break;
                case 4:
                        domenu();
@@ -451,7 +488,6 @@ kbdthread(void*)
 {
        Keyboardctl *realkc;
        Rune r;
-       static int paused;
 
        threadsetname("keyboard");
        realkc = initkeyboard(nil);
@@ -479,16 +515,16 @@ kbdthread(void*)
                        showa ^= 1;
                        break;
                case ' ':
-                       paused ^= 1;
                        if(paused) {
-                               cursor = &pausecursor;
-                               pause(0, 1);
-                       } else {
                                cursor = nil;
                                pause(1, 1);
+                       } else {
+                               cursor = &pausecursor;
+                               pause(0, 1);
                        }
                        setcursor(mc, cursor);
                }
+               drawglxy();
        }
 }